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.

Replaced `Product#taxonomy_ids` with a proper `Product#taxonomies` association

Damian Legawiec8e7a0d7813b5
diff --git a/core/app/models/spree/product.rb b/core/app/models/spree/product.rb
index fcc5e42bdb..b55903a41a 100644
--- a/core/app/models/spree/product.rb
+++ b/core/app/models/spree/product.rb
@@ -78,6 +78,7 @@ module Spree
has_many :classifications, dependent: :delete_all, inverse_of: :product
has_many :taxons, through: :classifications, before_remove: :remove_taxon
+ has_many :taxonomies, through: :taxons
has_many :product_promotion_rules, class_name: 'Spree::ProductPromotionRule'
has_many :promotion_rules, through: :product_promotion_rules, class_name: 'Spree::PromotionRule'
@@ -580,11 +581,6 @@ module Spree
@taxon_and_ancestors ||= taxons.map(&:self_and_ancestors).flatten.uniq
end
- # Get the taxonomy ids of all taxons assigned to this product and their ancestors.
- def taxonomy_ids
- @taxonomy_ids ||= taxon_and_ancestors.map(&:taxonomy_id).flatten.uniq
- end
-
# Iterate through this products taxons and taxonomies and touch their timestamps in a batch
def touch_taxons
Spree::Taxon.where(id: taxon_and_ancestors.map(&:id)).update_all(updated_at: Time.current)