mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-06 22:36:07 +00:00
Perform products cache refresh when producer property changed or destroyed
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user