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.

Add page_links associations to Product and Taxon models

Łukasz Adamczyka937000cc4f6
diff --git a/core/app/models/spree/product.rb b/core/app/models/spree/product.rb
index 2f3134f776..7cbf14d954 100644
--- a/core/app/models/spree/product.rb
+++ b/core/app/models/spree/product.rb
@@ -141,6 +141,8 @@ module Spree
has_many :stores, through: :store_products, class_name: 'Spree::Store'
has_many :digitals, through: :variants_including_master
+ has_many :page_links, as: :linkable, class_name: 'Spree::PageLink', dependent: :destroy
+
after_create :add_associations_from_prototype
after_create :build_variants_from_option_values_hash, if: :option_values_hash
diff --git a/core/app/models/spree/taxon.rb b/core/app/models/spree/taxon.rb
index e07877b6f4..f88f58803c 100644
--- a/core/app/models/spree/taxon.rb
+++ b/core/app/models/spree/taxon.rb
@@ -47,6 +47,8 @@ module Spree
has_many :promotion_rule_taxons, class_name: 'Spree::PromotionRuleTaxon', dependent: :destroy
has_many :promotion_rules, through: :promotion_rule_taxons, class_name: 'Spree::PromotionRule'
+ has_many :page_links, as: :linkable, class_name: 'Spree::PageLink', dependent: :destroy
+
#
# Attachments
#