Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

fix caching of Option Values filters

Łukasz Adamczyk0020e87e622a
diff --git a/core/app/models/spree/option_value_variant.rb b/core/app/models/spree/option_value_variant.rb
index 2262be06f9..f74fce82ff 100644
--- a/core/app/models/spree/option_value_variant.rb
+++ b/core/app/models/spree/option_value_variant.rb
@@ -1,7 +1,7 @@
module Spree
class OptionValueVariant < Spree::Base
belongs_to :option_value, class_name: 'Spree::OptionValue'
- belongs_to :variant, class_name: 'Spree::Variant'
+ belongs_to :variant, touch: true, class_name: 'Spree::Variant'
validates :option_value, :variant, presence: true
validates :option_value_id, uniqueness: { scope: :variant_id }
diff --git a/core/app/models/spree/variant.rb b/core/app/models/spree/variant.rb
index dcb1feb748..a92c7631d6 100644
--- a/core/app/models/spree/variant.rb
+++ b/core/app/models/spree/variant.rb
@@ -29,7 +29,7 @@ module Spree
end
has_many :option_value_variants, class_name: 'Spree::OptionValueVariant'
- has_many :option_values, through: :option_value_variants, class_name: 'Spree::OptionValue'
+ has_many :option_values, through: :option_value_variants, dependent: :destroy, class_name: 'Spree::OptionValue'
has_many :images, -> { order(:position) }, as: :viewable, dependent: :destroy, class_name: 'Spree::Image'
diff --git a/frontend/app/views/spree/shared/_option_values.html.erb b/frontend/app/views/spree/shared/_option_values.html.erb
index e628b14960..1dbb532a2b 100644
--- a/frontend/app/views/spree/shared/_option_values.html.erb
+++ b/frontend/app/views/spree/shared/_option_values.html.erb
@@ -1,5 +1,3 @@
-<% cache base_cache_key + [ot_downcase_name, params_ot_downcase_name, filtering_params_cache_key, @taxon&.id] do %>
- <% option_type.option_values.each do |option_value| %>
- <%= option_value_filter_link(option_value, permitted_params) %>
- <% end %>
+<% option_type.option_values.each do |option_value| %>
+ <%= option_value_filter_link(option_value, permitted_params) %>
<% end %>