From d43df754d3778797479ee0e85eb7982234f75772 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Tue, 10 Sep 2013 10:36:13 +1000 Subject: [PATCH] Load correct products on enterprise and product listing pages --- app/controllers/enterprises_controller.rb | 9 ++++++++- app/controllers/spree/products_controller_decorator.rb | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/controllers/enterprises_controller.rb b/app/controllers/enterprises_controller.rb index c6b3492a91..6659e6e2ce 100644 --- a/app/controllers/enterprises_controller.rb +++ b/app/controllers/enterprises_controller.rb @@ -31,7 +31,14 @@ class EnterprisesController < BaseController @enterprise = Enterprise.find params[:id] @products = [] - @products = current_order_cycle.products if current_order_cycle + + if current_order_cycle + @searcher = Spree::Config.searcher_class.new(options) + @products = @searcher.retrieve_products + + order_cycle_products = current_order_cycle.products + @products.select! { |p| order_cycle_products.include? p } + end end def shop diff --git a/app/controllers/spree/products_controller_decorator.rb b/app/controllers/spree/products_controller_decorator.rb index 54e7fadb9d..2f6468c0b5 100644 --- a/app/controllers/spree/products_controller_decorator.rb +++ b/app/controllers/spree/products_controller_decorator.rb @@ -6,7 +6,10 @@ Spree::ProductsController.class_eval do include OpenFoodWeb::SplitProductsByDistribution respond_override :index => { :html => { :success => lambda { - @products = current_order_cycle.products if current_order_cycle + if current_order_cycle + order_cycle_products = current_order_cycle.products + @products.select! { |p| order_cycle_products.include? p } + end } } } end