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.

Remove deprecated taxonomy initialization methods from Store (#14020)

Damian Legawiec0f50a647e944
diff --git a/spree/core/app/models/spree/store.rb b/spree/core/app/models/spree/store.rb
index 206769653b..2552685173 100644
--- a/spree/core/app/models/spree/store.rb
+++ b/spree/core/app/models/spree/store.rb
@@ -420,55 +420,6 @@ module Spree
channels.create!(name: 'Online Store', code: Spree::Channel::DEFAULT_CODE)
end
- def ensure_default_taxonomies_are_created
- Spree::Deprecation.warn('Store#ensure_default_taxonomies_are_created is deprecated and will be removed in Spree 5.5. Please remove it from your codebase')
-
- Spree::Events.disable do
- [
- translate_with_store_locale_fallback('spree.taxonomy_categories_name'),
- translate_with_store_locale_fallback('spree.taxonomy_brands_name'),
- translate_with_store_locale_fallback('spree.taxonomy_collections_name')
- ].each do |taxonomy_name|
- # Manual exists?/create to work around Mobility bug with find_or_create_by
- next if taxonomies.with_matching_name(taxonomy_name).exists?
-
- taxonomies.create(name: taxonomy_name)
- end
- end
- end
-
- def ensure_default_automatic_taxons
- Spree::Deprecation.warn('Store#ensure_default_automatic_taxons is deprecated and will be removed in Spree 5.5. Please remove it from your codebase')
-
- Spree::Events.disable do
- # Use Mobility-safe lookup for taxonomy
- collections_taxonomy = taxonomies.with_matching_name(translate_with_store_locale_fallback('spree.taxonomy_collections_name')).first
- return unless collections_taxonomy.present?
-
- automatic_taxons_config = [
- { name: translate_with_store_locale_fallback('spree.automatic_taxon_names.on_sale'),
- rule_type: 'Spree::TaxonRules::Sale', rule_value: 'true' },
- { name: translate_with_store_locale_fallback('spree.automatic_taxon_names.new_arrivals'), rule_type: 'Spree::TaxonRules::AvailableOn', rule_value: 30 }
- ]
-
- automatic_taxons_config.map do |config|
- # Manual exists?/create to work around Mobility bug with first_or_create
- taxon_scope = collections_taxonomy.taxons.automatic.with_matching_name(config[:name])
-
- if taxon_scope.exists?
- taxon_scope.first
- else
- collections_taxonomy.taxons.create!(
- name: config[:name],
- automatic: true,
- parent: collections_taxonomy.root,
- taxon_rules: [TaxonRule.new(type: config[:rule_type], value: config[:rule_value])]
- )
- end
- end
- end
- end
-
# Translates a key using the store's default locale with fallback to :en
def translate_with_store_locale_fallback(key)
locale = default_locale.presence&.to_sym || :en