Skip to content

Tech Doc: Scoping Variants and Products to Hubs with VariantOverrides

Luis Ramos edited this page Apr 11, 2019 · 2 revisions

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!

Clone this wiki locally