-
-
Notifications
You must be signed in to change notification settings - Fork 724
Tech Doc: Scoping Variants and Products to Hubs with VariantOverrides
In OFN we have Variant Overrides that "enable a stock level and price of a variant to be overridden for a specific Hub". At specific places we instrument the (mostly Spree) code with OpenFoodNetwork::ScopeVariantToHub and OpenFoodNetwork::ScopeVariantToHub to take into account hub level values (overides) instead of the standard ones at variant level.
In Spree v2, the variant.count_on_hand field was moved to a new table and entity called StockItem so that different stock levels can be managed for different stock locations. See more details about how we make OFN have a single stock locations here.
Currently in OFN v2 we adapt Variant class in VariantStock concern where we handle single stock location and thus single stock item per variant and then in ScopeVariantToHub we override the logic to keep using variant_overrides.count_on_hand value if it is an override that is being processed. This was a very simple solution to avoid having to create stock items for variant overrides!
Development environment setup
- Pipeline development process
- Bug severity
- Feature template (epic)
- Internationalisation (i18n)
- Dependency updates
Development
- Developer Guidelines
- The process of review, test, merge and deploy
- Making a great commit
- Making a great pull request
- Code Conventions
- Database migrations
- Testing and Rspec Tips
- Automated Testing Gotchas
- Rubocop
- Angular and OFN
- Feature toggles
- Stimulus and Turbo
Testing
- Testing process
- OFN Testing Documentation (Handbooks)
- Continuous Integration
- Parallelized test suite with knapsack
- Karma
Releasing
Specific features
Data and APIs
Instance-specific configuration
External services
Design