mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-27 06:05:19 +00:00
On enterprise page, do not display products outside of the outgoing exchange
This commit is contained in:
@@ -48,8 +48,8 @@ class EnterprisesController < BaseController
|
||||
@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 }
|
||||
order_cycle_products = current_order_cycle.products_distributed_by(current_distributor)
|
||||
@products = @products & order_cycle_products
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -97,6 +97,10 @@ class OrderCycle < ActiveRecord::Base
|
||||
map(&:variants).flatten.uniq
|
||||
end
|
||||
|
||||
def products_distributed_by(distributor)
|
||||
variants_distributed_by(distributor).map(&:product).uniq
|
||||
end
|
||||
|
||||
def products
|
||||
self.variants.map(&:product).uniq
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user