Sha256: 9e01a4a71d537c91b590dc415f05f5163f36be77395ce9a40ea20fab5dd26f49

Contents?: true

Size: 777 Bytes

Versions: 2

Compression:

Stored size: 777 Bytes

Contents

# frozen_string_literal: true

module Spree
  module SpreeProductDecorator
    def self.prepended(base)
      base.include AlchemySolidus::TouchAlchemyIngredients
      base.has_many :alchemy_ingredients, class_name: "Alchemy::Ingredients::SpreeProduct", as: :related_object, dependent: :nullify
    end

    private

    # Overwritten Solidus' default behavior
    #
    # The Solidus implementation did not trigger `touch` on taxons, but
    # updated the `updated_at` timestamp in an `update_all`.
    #
    # Since we want to invalidate ingredient spree taxons cache as well
    # we need to use `touch` here and use the `after_touch` callback of
    # Spree::Taxon
    #
    def touch_taxons
      taxons.each(&:touch)
    end

    ::Spree::Product.prepend self
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alchemy-solidus-7.4.0 app/decorators/models/spree/spree_product_decorator.rb
alchemy-solidus-7.3.2 app/decorators/models/spree/spree_product_decorator.rb