diff --git a/app/helpers/spree/base_helper_decorator.rb b/app/helpers/spree/base_helper_decorator.rb index fa04067c75..2d82170930 100644 --- a/app/helpers/spree/base_helper_decorator.rb +++ b/app/helpers/spree/base_helper_decorator.rb @@ -6,6 +6,10 @@ module Spree root_taxon.children.map do |taxon| css_class = (current_taxon && current_taxon.self_and_ancestors.include?(taxon)) ? 'current' : nil + # The concern of separating products by distributor and order cycle is dealt with in + # a few other places: OpenFoodWeb::Searcher (for searching over products) and in + # OpenFoodWeb::SplitProductsByDistributor (for splitting the main product display). + products = Product.in_taxon(taxon) products = products.in_distributor(current_distributor) if current_distributor products = products.in_order_cycle(current_order_cycle) if current_order_cycle diff --git a/lib/open_food_web/searcher.rb b/lib/open_food_web/searcher.rb index faaa10893e..46cf3337cd 100644 --- a/lib/open_food_web/searcher.rb +++ b/lib/open_food_web/searcher.rb @@ -14,6 +14,10 @@ module OpenFoodWeb def get_base_scope base_scope = super + # The concern of separating products by distributor and order cycle is dealt with in + # a few other places: OpenFoodWeb::SplitProductsByDistributor (for splitting the main + # product display) and Spree::BaseHelper decorator (for taxon counts). + base_scope = base_scope.in_supplier_or_distributor(enterprise_id) if enterprise_id base_scope = base_scope.in_supplier(supplier_id) if supplier_id base_scope = base_scope.in_distributor(distributor_id) if distributor_id diff --git a/lib/open_food_web/split_products_by_distributor.rb b/lib/open_food_web/split_products_by_distributor.rb index 37802a5860..7037d351da 100644 --- a/lib/open_food_web/split_products_by_distributor.rb +++ b/lib/open_food_web/split_products_by_distributor.rb @@ -1,6 +1,10 @@ module OpenFoodWeb - module SplitProductsByDistributor + # The concern of separating products by distributor and order cycle is dealt with in a few + # other places: OpenFoodWeb::Searcher (for searching over products) and in + # Spree::BaseHelper decorator (for taxon counts). + + module SplitProductsByDistributor # If a distributor is provided, split the list of products into local (at that # distributor) and remote (at another distributor). If a distributor is not # provided, perform no split.