Perform products cache refresh when producer property changed or destroyed

This commit is contained in:
Rohan Mitchell
2016-02-24 16:11:59 +11:00
parent 1b62dd06b8
commit 71862e00a7
3 changed files with 52 additions and 0 deletions

View File

@@ -42,10 +42,19 @@ module OpenFoodNetwork
def self.producer_property_changed(producer_property)
products = producer_property.producer.supplied_products
variants = Spree::Variant.
where(is_master: false, deleted_at: nil).
where(product_id: products)
exchanges_featuring_variants(variants).each do |exchange|
refresh_cache exchange.receiver, exchange.order_cycle
end
end
def self.producer_property_destroyed(producer_property)
producer_property_changed producer_property
end