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.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
feat(core): deprecation warnings for taxon->category aliases
Łukasz Adamczyk73a8a5a1cfea
diff --git a/docs/plans/6.0-replace-taxons-with-categories.md b/docs/plans/6.0-replace-taxons-with-categories.mdindex 18bfd519e5..fb9eb0c18d 100644--- a/docs/plans/6.0-replace-taxons-with-categories.md+++ b/docs/plans/6.0-replace-taxons-with-categories.md@@ -586,7 +586,7 @@ end- **`classification_count` is dropped now** (not deferred). The direct taxon-side Rails counter was only read by the legacy `spree/admin` engine; the descendant-inclusive `products_count` is kept. The product-side counter is renamed `classification_count` → `categories_count`. `Classification`'s counter_cache follows to `categories_count`; the three taxon bulk services recompute `products_count` via `recalculate_products_count` instead of the removed counter. Legacy `spree/admin` views that read `taxon.classification_count` are **not** fixed (that engine is being replaced by the SPA) — the specs they break are marked `pending`.- **Mobility translation table is renamed here too** (`spree_taxon_translations` → `spree_category_translations`, `spree_taxon_id` → `spree_category_id`), for consistency with the other table renames. Once the class is renamed to `Spree::Category` (Phase 3), Mobility derives `spree_category_translations` / `spree_category_id` naturally, so **no `translates` pin** is needed in delivered 6.0. (A Phase-2-only intermediate — class still `Spree::Taxon`, table already renamed — would need a transient pin to the *new* table, but 6.0 ships all phases together.)-- **Automatic-taxon matching code is removed here** (see Phase 3 rationale). Because 6.0 is single-delivery, the taxon auto-match path doesn't need to survive the rename: deleted `Products::AutoMatchTaxons` (+ job), `Taxons::RegenerateProducts`, `Product#auto_match_taxons` + `after_commit`, `Product.bulk_auto_match_taxons`, `Taxon#regenerate_taxon_products` + `after_commit`, and the `TaxonRule` regeneration callback. Rule-based membership now lives on `Collection`. `Price` re-match + the bulk-tags API endpoint now trigger `auto_match_collections` / `Product.bulk_auto_match_collections`; the bulk-category endpoints no longer re-match (category membership never affected rule matching).+- **Automatic-taxon matching code is removed here** (see Phase 3 rationale). Because 6.0 is single-delivery, the taxon auto-match path doesn't need to survive the rename: removed `Product#auto_match_taxons` + `after_commit`, `Product.bulk_auto_match_taxons`, `Taxon#regenerate_taxon_products` + `after_commit`, and the `TaxonRule` regeneration callback. Rule-based membership now lives on `Collection`. `Price` re-match + the bulk-tags API endpoint now trigger `auto_match_collections` / `Product.bulk_auto_match_collections`; the bulk-category endpoints no longer re-match (category membership never affected rule matching). The **service/job classes** `Products::AutoMatchTaxons` (+ its job) and `Taxons::RegenerateProducts` are retained as deprecating aliases (see Phase 3's "Deprecation aliases" note), not deleted.- **`eligible_for_taxon_matching?` → `eligible_for_collection_matching?`** (the `Product` predicate + the `Price` attribute).### Phase 3: Class renames + deprecation aliases@@ -608,7 +608,12 @@ Now that Collections exist (Phase 1) and the tables are renamed (Phase 2), renam- **Brand removal (moved here from 6.1):** delete `Product#brand_taxon` / `#brand_name` (+ the `MEMOIZED_METHODS` entry), the `brand` field on the Products Performance report, and the `brand_name` column from the product CSV export — brands are out of scope with no replacement (see Key Decisions → Brands). The `spree_taxonomies` table + `taxonomy_brands_name` locale key still drop in 6.1 with `Taxonomy`; only the brand *methods/fields* go now.- **Wording sweep** (Ruby names → category): `Product#main_taxon` → `#primary_category` (deprecated delegate), `touch_taxons` → `touch_categories`, `Spree::Products::TouchTaxonsJob` → `TouchCategoriesJob` + `Spree.queues.taxons` → `categories` (both with deprecation aliases), `taxon_and_ancestors` → `category_and_ancestors`, `remove_taxon` → `remove_category`, the `grouped_taxon_ids_for_products` scope → `grouped_category_ids_for_products`, and `recalculate_products_count`'s param; delete the dead, buggy `Product#taxons_for_store`. Comments/param names across `Category`/`Product` de-taxoned.- **Remove the deprecated taxon-tied `Product` scopes** marked remove-in-6.0: `in_taxons`, `for_filters`, `taxons_name_eq`, plus their now-orphaned private helpers `prepare_taxon_conditions` / `get_taxons`. The active scopes stay (`in_taxon`, `in_category`, `in_categories`, `in_collection`, `ascend_by_taxons_min_position`). Non-taxon deprecated scopes (master-price, option, name, etc.) are left for their own plans.-- **Rename the manual-membership services** `Spree::Taxons::AddProducts` / `RemoveProducts` → `Spree::Categories::AddProducts` / `RemoveProducts` (param `taxons:` → `categories:`, matching `Spree::Collections::*`). No alias — a clean 6.0 break with all monorepo callers updated (Phase 2 already removed the sibling `Spree::Taxons::RegenerateProducts` without one). The optional `Spree::Taxons::TouchFeaturedSections` hook (guarded by `defined?`, its namespace owned by another gem) is left untouched.+- **Rename the manual-membership services** `Spree::Taxons::AddProducts` / `RemoveProducts` → `Spree::Categories::AddProducts` / `RemoveProducts` (param `taxons:` → `categories:`, matching `Spree::Collections::*`). All monorepo callers move to the new names, but the old classes are **kept as deprecating aliases** (see "Deprecation aliases" below). The optional `Spree::Taxons::TouchFeaturedSections` hook (guarded by `defined?`, its namespace owned by another gem) is left untouched.+- **Deprecation aliases (kept for one release, removed in 6.1).** Every renamed/moved taxon name keeps working with a runtime deprecation warning:+ - **Model constants** (`Spree::Taxon`, `Spree::Classification`, `Spree::PromotionRuleTaxon`, `Spree::Promotion::Rules::Taxon`) stay **true constant aliases** — not `DeprecatedConstantProxy`, which silently breaks `is_a?`/`case`/STI/polymorphic-`constantize`. Each calls `Spree::Deprecation.warn` in the alias's module body, so the notice fires through Spree's deprecator when the file loads (at boot under eager load, on first reference otherwise). Since a plain alias is the same object as the canonical class, a reliable *per-reference* warning isn't achievable without a proxy (breaks `is_a?`) or `const_missing` (breaks `defined?`), so the load-time notice is the deliberate trade-off.+ - **Service/job classes** are resurrected as thin deprecating wrappers that `Spree::Deprecation.warn` on invocation and delegate: `Taxons::AddProducts`/`RemoveProducts` translate `taxons:` → `categories:`; `Products::AutoMatchTaxons` (+ `AutoMatchTaxonsJob`) and `Products::TouchTaxonsJob` delegate to their `*Collections*`/`*Categories*` counterparts; `Taxons::RegenerateProducts` warns and no-ops (categories are manual in 6.0 — its behavior only survives for `Collection`, keyed on a collection rather than a taxon, so there is no faithful delegate).+ - **`Spree.queues.taxons`** is restored as a singleton method that warns and returns `Spree.queues.categories`.+ - **Method bridges** (`Product#taxons`/`taxon_ids`/`main_taxon`/`classifications`, `Store#taxons`, the join models' `#taxon`, the rule's `#taxons`/`#taxon_ids`/`#eligible_taxon_ids`/`#taxon_ids_to_add`/`#taxon_ids_string`) each `Spree::Deprecation.warn` and delegate. Internal core callers were repointed to the canonical names so the warnings only fire for external code. (`Spree::Taxonomy` and `Spree::Taxons::Find` are themselves legacy/dropped in 6.1 and keep referencing the `Taxon` constant internally.)### Phase 4: Data migration (rake task)@@ -672,12 +677,13 @@ Gated on the channels plan finishing the `available_on` → `ProductPublication#- Remove `automatic`, `rules_match_policy`, `sort_order` columns from categories (moved to collections)- **Drop `spree_taxon_rules` + `Spree::TaxonRule` / `TaxonRules::*` + the `config.spree.taxon_rules` registry** (retained data-only through 6.0 so the Phase 4 data migration can read them; rows were copied to `spree_collection_rules`, and `CollectionRule` is net-new so there's no alias to keep)- Remove the deprecated Ruby-level aliases kept through 6.0: the `taxons` and `classifications` method aliases on `Product`/`Category`/`Store`, the `taxon`/`taxon=` readers on the join models, and the rule's `taxons`/`taxon_ids`/`eligible_taxon_ids`/`taxon_ids_to_add` aliases+- Remove the deprecated **constant + service/job/queue aliases** kept through 6.0: `Spree::Taxon`, `Spree::Classification`, `Spree::PromotionRuleTaxon`, `Spree::Promotion::Rules::Taxon` (constant aliases + their load-time `Spree::Deprecation.warn`); the `Spree::Taxons::AddProducts`/`RemoveProducts`/`RegenerateProducts`, `Spree::Products::AutoMatchTaxons`/`AutoMatchTaxonsJob`/`TouchTaxonsJob` wrappers; and the `Spree.queues.taxons` singleton method- Rename `spree_prototype_taxons` (with `6.0-product-types.md`), dropping the `foreign_key: :taxon_id` pin on `Category#prototype_taxons` (the `#taxon_rules` pin goes away with the `spree_taxon_rules` drop above)## Constraints on Current Work- **Use `categories` in all new API code.** The Store API already does this. Don't introduce new `taxon` references in API v3.-- **Use `Spree::Category` alias in new code where possible.** It exists today as `< Taxon`.+- **Use `Spree::Category` in new code.** It is the canonical class now; `Spree::Taxon` is a deprecation alias (removed in 6.1).- **Don't add new TaxonRule subtypes.** `TaxonRule` is data-only from 6.0 (matching removed); new rule types go on `CollectionRule`.- **Don't add new Taxonomy-dependent features.** Taxonomy is going away.- **Keep the `ctg_` prefix.** Already in use, will carry over.diff --git a/spree/core/app/jobs/spree/imports/create_categories_job.rb b/spree/core/app/jobs/spree/imports/create_categories_job.rbindex 94973c37bb..e9ef943ba6 100644--- a/spree/core/app/jobs/spree/imports/create_categories_job.rb+++ b/spree/core/app/jobs/spree/imports/create_categories_job.rb@@ -9,9 +9,9 @@ module Spreedef perform(product_id, store_id, taxon_pretty_names)product = Spree::Product.find(product_id)store = Spree::Store.find(store_id)- taxons = taxon_pretty_names.filter_map { |taxon_pretty_name| find_or_create_taxon(store, taxon_pretty_name) }+ categories = taxon_pretty_names.filter_map { |taxon_pretty_name| find_or_create_taxon(store, taxon_pretty_name) }- product.taxons = taxons+ product.categories = categoriesendprivatediff --git a/spree/core/app/jobs/spree/products/auto_match_taxons_job.rb b/spree/core/app/jobs/spree/products/auto_match_taxons_job.rbnew file mode 100644index 0000000000..c4c19e562f--- /dev/null+++ b/spree/core/app/jobs/spree/products/auto_match_taxons_job.rb@@ -0,0 +1,13 @@+module Spree+ module Products+ # @deprecated Renamed to AutoMatchCollectionsJob in 6.0 (behavior moved to+ # collections). Subclasses it so jobs enqueued under the old class name still+ # deserialize and run; removed in 6.1.+ class AutoMatchTaxonsJob < AutoMatchCollectionsJob+ def perform(product_id)+ Spree::Deprecation.warn('Spree::Products::AutoMatchTaxonsJob is deprecated and will be removed in Spree 6.1. Use Spree::Products::AutoMatchCollectionsJob instead.')+ super+ end+ end+ end+enddiff --git a/spree/core/app/jobs/spree/products/touch_taxons_job.rb b/spree/core/app/jobs/spree/products/touch_taxons_job.rbindex 3287b9b1ff..30c4b22ef9 100644--- a/spree/core/app/jobs/spree/products/touch_taxons_job.rb+++ b/spree/core/app/jobs/spree/products/touch_taxons_job.rb@@ -1,8 +1,13 @@module Spreemodule Products- # Deprecation alias for Spree::Products::TouchCategoriesJob, renamed in 6.0.- # Kept so any job enqueued under the old class name before the deploy still- # deserializes; removed in 6.1.- TouchTaxonsJob = TouchCategoriesJob+ # @deprecated Renamed to Spree::Products::TouchCategoriesJob in 6.0. Subclasses it+ # so jobs enqueued under the old class name before the deploy still deserialize+ # and run; removed in 6.1.+ class TouchTaxonsJob < TouchCategoriesJob+ def perform(*args)+ Spree::Deprecation.warn('Spree::Products::TouchTaxonsJob is deprecated and will be removed in Spree 6.1. Use Spree::Products::TouchCategoriesJob instead.')+ super+ end+ endendenddiff --git a/spree/core/app/models/spree/classification.rb b/spree/core/app/models/spree/classification.rbindex a3ee0b943c..da8713a8da 100644--- a/spree/core/app/models/spree/classification.rb+++ b/spree/core/app/models/spree/classification.rb@@ -2,6 +2,9 @@module Spree# Deprecation alias for Spree::ProductCategory, renamed from Spree::Classification- # in 6.0. Kept for one release so existing references keep resolving; removed in 6.1.+ # in 6.0. A true constant alias (AR-safe); the warning fires when this file loads.+ # Removed in 6.1.Classification = ProductCategory++ Spree::Deprecation.warn('Spree::Classification is deprecated and will be removed in Spree 6.1. Use Spree::ProductCategory instead.')enddiff --git a/spree/core/app/models/spree/product.rb b/spree/core/app/models/spree/product.rbindex 4196cd0b95..9ef2f2ac2e 100644--- a/spree/core/app/models/spree/product.rb+++ b/spree/core/app/models/spree/product.rb@@ -72,23 +72,28 @@ module Spree# @deprecated Use #product_categories; removed in 6.1.def classifications+ Spree::Deprecation.warn('Spree::Product#classifications is deprecated and will be removed in Spree 6.1. Use #product_categories instead.')product_categoriesend# @deprecated Use #categories / #category_ids; removed in 6.1.def taxons+ Spree::Deprecation.warn('Spree::Product#taxons is deprecated and will be removed in Spree 6.1. Use #categories instead.')categoriesenddef taxons=(value)+ Spree::Deprecation.warn('Spree::Product#taxons= is deprecated and will be removed in Spree 6.1. Use #categories= instead.')self.categories = valueenddef taxon_ids+ Spree::Deprecation.warn('Spree::Product#taxon_ids is deprecated and will be removed in Spree 6.1. Use #category_ids instead.')category_idsenddef taxon_ids=(ids)+ Spree::Deprecation.warn('Spree::Product#taxon_ids= is deprecated and will be removed in Spree 6.1. Use #category_ids= instead.')self.category_ids = idsend@@ -605,6 +610,7 @@ module Spree# @deprecated Use {#primary_category}.def main_taxon+ Spree::Deprecation.warn('Spree::Product#main_taxon is deprecated and will be removed in Spree 6.1. Use #primary_category instead.')primary_categoryenddiff --git a/spree/core/app/models/spree/product_category.rb b/spree/core/app/models/spree/product_category.rbindex e3e1236148..7344715986 100644--- a/spree/core/app/models/spree/product_category.rb+++ b/spree/core/app/models/spree/product_category.rb@@ -48,10 +48,12 @@ module Spree# @deprecated Use #category / #category=; removed in 6.1.def taxon+ Spree::Deprecation.warn('Spree::ProductCategory#taxon is deprecated and will be removed in Spree 6.1. Use #category instead.')categoryenddef taxon=(value)+ Spree::Deprecation.warn('Spree::ProductCategory#taxon= is deprecated and will be removed in Spree 6.1. Use #category= instead.')self.category = valueenddiff --git a/spree/core/app/models/spree/promotion/rules/category.rb b/spree/core/app/models/spree/promotion/rules/category.rbindex c50f8ffc62..7569f29a68 100644--- a/spree/core/app/models/spree/promotion/rules/category.rb+++ b/spree/core/app/models/spree/promotion/rules/category.rb@@ -82,47 +82,52 @@ module Spree## @deprecated Use #categories.def taxons+ Spree::Deprecation.warn('Spree::Promotion::Rules::Category#taxons is deprecated and will be removed in Spree 6.1. Use #categories instead.')categoriesend# @deprecated Use #categories=.def taxons=(value)+ Spree::Deprecation.warn('Spree::Promotion::Rules::Category#taxons= is deprecated and will be removed in Spree 6.1. Use #categories= instead.')self.categories = valueend# @deprecated Use #category_ids.def taxon_ids+ Spree::Deprecation.warn('Spree::Promotion::Rules::Category#taxon_ids is deprecated and will be removed in Spree 6.1. Use #category_ids instead.')category_idsend# @deprecated Use #category_ids=.def taxon_ids=(ids)+ Spree::Deprecation.warn('Spree::Promotion::Rules::Category#taxon_ids= is deprecated and will be removed in Spree 6.1. Use #category_ids= instead.')self.category_ids = idsend# @deprecated Use #eligible_category_ids.- alias eligible_taxon_ids eligible_category_ids+ def eligible_taxon_ids+ Spree::Deprecation.warn('Spree::Promotion::Rules::Category#eligible_taxon_ids is deprecated and will be removed in Spree 6.1. Use #eligible_category_ids instead.')+ eligible_category_ids+ end# @deprecated Use #category_ids_to_add.def taxon_ids_to_add+ Spree::Deprecation.warn('Spree::Promotion::Rules::Category#taxon_ids_to_add is deprecated and will be removed in Spree 6.1. Use #category_ids_to_add instead.')category_ids_to_addenddef taxon_ids_to_add=(ids)+ Spree::Deprecation.warn('Spree::Promotion::Rules::Category#taxon_ids_to_add= is deprecated and will be removed in Spree 6.1. Use #category_ids_to_add= instead.')self.category_ids_to_add = idsenddef taxon_ids_string- ActiveSupport::Deprecation.warn(- 'Please use `category_ids=` instead.'- )+ Spree::Deprecation.warn('Spree::Promotion::Rules::Category#taxon_ids_string is deprecated and will be removed in Spree 6.1. Use #category_ids instead.')categories.pluck(:id).join(',')enddef taxon_ids_string=(s)- ActiveSupport::Deprecation.warn(- 'Please use `category_ids=` instead.'- )+ Spree::Deprecation.warn('Spree::Promotion::Rules::Category#taxon_ids_string= is deprecated and will be removed in Spree 6.1. Use #category_ids= instead.')ids = s.to_s.split(',').map(&:strip)self.categories = Spree::Category.for_stores(stores).find(ids)enddiff --git a/spree/core/app/models/spree/promotion/rules/taxon.rb b/spree/core/app/models/spree/promotion/rules/taxon.rbindex 6aa93c03de..ed7bff9cad 100644--- a/spree/core/app/models/spree/promotion/rules/taxon.rb+++ b/spree/core/app/models/spree/promotion/rules/taxon.rb@@ -4,9 +4,13 @@ module Spreeclass Promotionmodule Rules# Deprecation alias for Spree::Promotion::Rules::Category, renamed from- # Spree::Promotion::Rules::Taxon in 6.0. Old STI type strings still resolve- # through this alias until the Phase 4 data migration rewrites them. Removed in 6.1.+ # Spree::Promotion::Rules::Taxon in 6.0. A true constant alias, so old STI type+ # strings (`'Spree::Promotion::Rules::Taxon'`) still instantiate correctly until+ # the Phase 4 migration rewrites them. The warning fires when this file loads.+ # Removed in 6.1.Taxon = Category++ Spree::Deprecation.warn('Spree::Promotion::Rules::Taxon is deprecated and will be removed in Spree 6.1. Use Spree::Promotion::Rules::Category instead.')endendenddiff --git a/spree/core/app/models/spree/promotion_rule_category.rb b/spree/core/app/models/spree/promotion_rule_category.rbindex 158f91acb4..b50e0b48ef 100644--- a/spree/core/app/models/spree/promotion_rule_category.rb+++ b/spree/core/app/models/spree/promotion_rule_category.rb@@ -11,10 +11,12 @@ module Spree# @deprecated Use #category / #category=; removed in 6.1.def taxon+ Spree::Deprecation.warn('Spree::PromotionRuleCategory#taxon is deprecated and will be removed in Spree 6.1. Use #category instead.')categoryenddef taxon=(value)+ Spree::Deprecation.warn('Spree::PromotionRuleCategory#taxon= is deprecated and will be removed in Spree 6.1. Use #category= instead.')self.category = valueendenddiff --git a/spree/core/app/models/spree/promotion_rule_taxon.rb b/spree/core/app/models/spree/promotion_rule_taxon.rbindex 52f8aa38e4..0355b1c8c7 100644--- a/spree/core/app/models/spree/promotion_rule_taxon.rb+++ b/spree/core/app/models/spree/promotion_rule_taxon.rb@@ -2,6 +2,9 @@module Spree# Deprecation alias for Spree::PromotionRuleCategory, renamed from- # Spree::PromotionRuleTaxon in 6.0. Kept for one release; removed in 6.1.+ # Spree::PromotionRuleTaxon in 6.0. A true constant alias (AR-safe); the warning+ # fires when this file loads. Removed in 6.1.PromotionRuleTaxon = PromotionRuleCategory++ Spree::Deprecation.warn('Spree::PromotionRuleTaxon is deprecated and will be removed in Spree 6.1. Use Spree::PromotionRuleCategory instead.')enddiff --git a/spree/core/app/models/spree/store.rb b/spree/core/app/models/spree/store.rbindex 6ce626a570..aed72f54f9 100644--- a/spree/core/app/models/spree/store.rb+++ b/spree/core/app/models/spree/store.rb@@ -103,10 +103,12 @@ module Spree# @deprecated Use #categories; removed in 6.1.def taxons+ Spree::Deprecation.warn('Spree::Store#taxons is deprecated and will be removed in Spree 6.1. Use #categories instead.')categoriesenddef taxons=(value)+ Spree::Deprecation.warn('Spree::Store#taxons= is deprecated and will be removed in Spree 6.1. Use #categories= instead.')self.categories = valueenddiff --git a/spree/core/app/models/spree/taxon.rb b/spree/core/app/models/spree/taxon.rbindex ec36541f43..da57813b0b 100644--- a/spree/core/app/models/spree/taxon.rb+++ b/spree/core/app/models/spree/taxon.rb@@ -7,6 +7,11 @@ module Spree# in 6.1 (along with the spree_taxonomies table and the automatic-taxon columns).## This is a true constant alias — the underlying class, table (spree_categories),- # prefix (ctg), and model_name are all Spree::Category. Only the constant differs.+ # prefix (ctg), and model_name are all Spree::Category. Only the constant differs,+ # so is_a?, STI, polymorphic *_type strings, and class_name: references keep+ # resolving to Spree::Category. The warning below fires through Spree's deprecator+ # when this file loads (at boot under eager load, on first reference otherwise).Taxon = Category++ Spree::Deprecation.warn('Spree::Taxon is deprecated and will be removed in Spree 6.1. Use Spree::Category instead.')enddiff --git a/spree/core/app/presenters/spree/search_provider/product_presenter.rb b/spree/core/app/presenters/spree/search_provider/product_presenter.rbindex b045b6f902..9486c4673e 100644--- a/spree/core/app/presenters/spree/search_provider/product_presenter.rb+++ b/spree/core/app/presenters/spree/search_provider/product_presenter.rb@@ -65,7 +65,7 @@ module Spreechannel_ids: channel_ids_for_store,discontinue_on: product.discontinue_on&.to_i || 0,category_ids: category_ids_with_ancestors,- category_names: product.taxons.map { |t| translated(t, :name, fallback_locale) },+ category_names: product.categories.map { |t| translated(t, :name, fallback_locale) },collection_ids: product.collections.map(&:prefixed_id),option_type_ids: product.option_types.map(&:prefixed_id),option_type_names: product.option_types.map { |ot| translated(ot, :presentation, fallback_locale) },@@ -121,7 +121,7 @@ module Spreeenddef category_ids_with_ancestors- @category_ids_with_ancestors ||= product.taxons.flat_map { |t|+ @category_ids_with_ancestors ||= product.categories.flat_map { |t|t.self_and_ancestors.map(&:prefixed_id)}.uniqenddiff --git a/spree/core/app/services/spree/products/auto_match_taxons.rb b/spree/core/app/services/spree/products/auto_match_taxons.rbnew file mode 100644index 0000000000..f3f7e04770--- /dev/null+++ b/spree/core/app/services/spree/products/auto_match_taxons.rb@@ -0,0 +1,17 @@+module Spree+ module Products+ # @deprecated Automatic taxon matching moved to Spree::Collection in 6.0.+ # Delegates to Spree::Products::AutoMatchCollections (same `product:` signature);+ # removed in 6.1.+ class AutoMatchTaxons+ prepend ::Spree::ServiceModule::Base++ # @param product [Spree::Product]+ # @return [Spree::ServiceModule::Base::Result]+ def call(product:)+ Spree::Deprecation.warn('Spree::Products::AutoMatchTaxons is deprecated and will be removed in Spree 6.1. Automatic membership moved to collections; use Spree::Products::AutoMatchCollections instead.')+ Spree::Products::AutoMatchCollections.call(product: product)+ end+ end+ end+enddiff --git a/spree/core/app/services/spree/products/duplicator.rb b/spree/core/app/services/spree/products/duplicator.rbindex 9a9d610c44..5e7a477e69 100644--- a/spree/core/app/services/spree/products/duplicator.rb+++ b/spree/core/app/services/spree/products/duplicator.rb@@ -29,7 +29,7 @@ module Spreenew_product.status = :draftnew_product.name = "COPY OF #{product.name}"- new_product.taxons = product.taxons+ new_product.categories = product.categoriesnew_product.channels = product.channelsnew_product.created_at = nilnew_product.deleted_at = nildiff --git a/spree/core/app/services/spree/taxons/add_products.rb b/spree/core/app/services/spree/taxons/add_products.rbnew file mode 100644index 0000000000..ae08398bbf--- /dev/null+++ b/spree/core/app/services/spree/taxons/add_products.rb@@ -0,0 +1,18 @@+module Spree+ module Taxons+ # @deprecated Renamed to Spree::Categories::AddProducts in 6.0. This shim keeps+ # the old `taxons:` keyword working by delegating to the renamed service;+ # removed in 6.1.+ class AddProducts+ prepend Spree::ServiceModule::Base++ # @param taxons [Array<Spree::Category>]+ # @param products [Array<Spree::Product>]+ # @return [Spree::ServiceModule::Base::Result]+ def call(taxons:, products:)+ Spree::Deprecation.warn('Spree::Taxons::AddProducts is deprecated and will be removed in Spree 6.1. Use Spree::Categories::AddProducts instead.')+ Spree::Categories::AddProducts.call(categories: taxons, products: products)+ end+ end+ end+enddiff --git a/spree/core/app/services/spree/taxons/regenerate_products.rb b/spree/core/app/services/spree/taxons/regenerate_products.rbnew file mode 100644index 0000000000..5fc7d8bfeb--- /dev/null+++ b/spree/core/app/services/spree/taxons/regenerate_products.rb@@ -0,0 +1,18 @@+module Spree+ module Taxons+ # @deprecated Categories are manual in 6.0 and no longer regenerate membership+ # from rules — that behavior moved to Spree::Collection. There is no faithful+ # category target, so this shim warns and no-ops (returns the given taxon).+ # Use Spree::Collections::RegenerateProducts for collections. Removed in 6.1.+ class RegenerateProducts+ prepend ::Spree::ServiceModule::Base++ # @param taxon [Spree::Category] accepted for signature compatibility; ignored+ # @return [Spree::ServiceModule::Base::Result]+ def call(taxon: nil)+ Spree::Deprecation.warn('Spree::Taxons::RegenerateProducts is deprecated and does nothing in Spree 6.0 — categories are manual. Rule-based membership moved to Spree::Collection; use Spree::Collections::RegenerateProducts. Removed in 6.1.')+ success(taxon)+ end+ end+ end+enddiff --git a/spree/core/app/services/spree/taxons/remove_products.rb b/spree/core/app/services/spree/taxons/remove_products.rbnew file mode 100644index 0000000000..3d43dfbbed--- /dev/null+++ b/spree/core/app/services/spree/taxons/remove_products.rb@@ -0,0 +1,18 @@+module Spree+ module Taxons+ # @deprecated Renamed to Spree::Categories::RemoveProducts in 6.0. This shim keeps+ # the old `taxons:` keyword working by delegating to the renamed service;+ # removed in 6.1.+ class RemoveProducts+ prepend Spree::ServiceModule::Base++ # @param taxons [Array<Spree::Category>]+ # @param products [Array<Spree::Product>]+ # @return [Spree::ServiceModule::Base::Result]+ def call(taxons:, products:)+ Spree::Deprecation.warn('Spree::Taxons::RemoveProducts is deprecated and will be removed in Spree 6.1. Use Spree::Categories::RemoveProducts instead.')+ Spree::Categories::RemoveProducts.call(categories: taxons, products: products)+ end+ end+ end+enddiff --git a/spree/core/lib/spree/core.rb b/spree/core/lib/spree/core.rbindex feef1201e0..781beb76de 100644--- a/spree/core/lib/spree/core.rb+++ b/spree/core/lib/spree/core.rb@@ -115,7 +115,13 @@ module Spreeapi_keys: :default,search: :default,stock_reservations: :default- )+ ).tap do |queues|+ # @deprecated The taxons queue was renamed to categories in 6.0; removed in 6.1.+ queues.define_singleton_method(:taxons) do+ Spree::Deprecation.warn('Spree.queues.taxons is deprecated and will be removed in Spree 6.1. Use Spree.queues.categories instead.') if defined?(Spree::Deprecation)+ categories+ end+ endend# @deprecated Spree.searcher_class is deprecated and will be removed in Spree 5.5. Use Spree.search_provider instead.diff --git a/spree/core/lib/spree/testing_support/factories/classification_factory.rb b/spree/core/lib/spree/testing_support/factories/classification_factory.rbindex ce83fb9127..05858a4114 100644--- a/spree/core/lib/spree/testing_support/factories/classification_factory.rb+++ b/spree/core/lib/spree/testing_support/factories/classification_factory.rb@@ -1,7 +1,8 @@FactoryBot.define do- factory :classification, class: Spree::ProductCategory do+ # :classification is the pre-6.0 name, kept as an alias of the renamed :product_category.+ factory :product_category, class: Spree::ProductCategory, aliases: [:classification] doproduct- taxon+ categoryposition { 1 }enddiff --git a/spree/core/spec/models/spree/taxon_category_aliases_spec.rb b/spree/core/spec/models/spree/taxon_category_aliases_spec.rbnew file mode 100644index 0000000000..af48dfea13--- /dev/null+++ b/spree/core/spec/models/spree/taxon_category_aliases_spec.rb@@ -0,0 +1,115 @@+require 'spec_helper'++# Covers the Taxon -> Category deprecation aliases (renamed in 6.0, removed in 6.1):+# constant aliases stay real classes (AR-safe), and every resurrected service/job,+# the taxons queue, and the method bridges warn through Spree::Deprecation.+RSpec.describe 'Taxon -> Category deprecation aliases' do+ describe 'constant aliases resolve to the canonical class' do+ it 'keeps them as true class aliases (not proxies), so is_a?/STI stay correct' do+ expect(Spree::Taxon).to equal(Spree::Category)+ expect(Spree::Classification).to equal(Spree::ProductCategory)+ expect(Spree::PromotionRuleTaxon).to equal(Spree::PromotionRuleCategory)+ expect(Spree::Promotion::Rules::Taxon).to equal(Spree::Promotion::Rules::Category)+ end+ end++ describe Spree::Taxons::AddProducts do+ it 'warns and delegates to Spree::Categories::AddProducts (adds the products)' do+ category = create(:taxon)+ product = create(:product)++ expect(Spree::Deprecation).to receive(:warn).with(/Spree::Categories::AddProducts/)+ described_class.call(taxons: [category], products: [product])++ expect(category.reload.products).to include(product)+ end+ end++ describe Spree::Taxons::RemoveProducts do+ it 'warns and delegates to Spree::Categories::RemoveProducts (removes the products)' do+ category = create(:taxon)+ product = create(:product)+ create(:product_category, category: category, product: product)++ expect(Spree::Deprecation).to receive(:warn).with(/Spree::Categories::RemoveProducts/)+ described_class.call(taxons: [category], products: [product])++ expect(category.reload.products).not_to include(product)+ end+ end++ describe Spree::Taxons::RegenerateProducts do+ it 'warns and no-ops (categories are manual in 6.0)' do+ expect(Spree::Deprecation).to receive(:warn).with(/manual/)+ result = described_class.call(taxon: double(:category))++ expect(result).to be_success+ end+ end++ describe Spree::Products::AutoMatchTaxons do+ it 'warns and delegates to the renamed AutoMatchCollections service' do+ product = create(:product)++ expect(Spree::Deprecation).to receive(:warn).with(/AutoMatchCollections/)+ result = described_class.call(product: product)++ expect(result).to be_a(Spree::ServiceModule::Result)+ end+ end++ describe Spree::Products::AutoMatchTaxonsJob do+ it 'is a subclass of the renamed job and warns on perform' do+ expect(described_class.superclass).to eq(Spree::Products::AutoMatchCollectionsJob)++ product = create(:product)+ expect(Spree::Deprecation).to receive(:warn).with(/AutoMatchCollectionsJob/)++ expect { described_class.new.perform(product.id) }.not_to raise_error+ end+ end++ describe Spree::Products::TouchTaxonsJob do+ it 'is a subclass of the renamed job and warns on perform' do+ expect(described_class.superclass).to eq(Spree::Products::TouchCategoriesJob)++ category = create(:taxon)+ expect(Spree::Deprecation).to receive(:warn).with(/TouchCategoriesJob/)++ expect { described_class.new.perform([category.id], []) }.not_to raise_error+ end+ end++ describe 'Spree.queues.taxons' do+ it 'warns and returns the categories queue' do+ expect(Spree::Deprecation).to receive(:warn).with(/Spree.queues.categories/)+ expect(Spree.queues.taxons).to eq(Spree.queues.categories)+ end+ end++ describe 'method bridges' do+ it 'Spree::Product#taxons warns and returns #categories' do+ product = create(:product)+ expect(Spree::Deprecation).to receive(:warn).with(/#categories/)+ expect(product.taxons).to eq(product.categories)+ end++ it 'Spree::Product#main_taxon warns and returns #primary_category' do+ product = create(:product)+ expect(Spree::Deprecation).to receive(:warn).with(/#primary_category/)+ expect(product.main_taxon).to eq(product.primary_category)+ end++ it 'Spree::ProductCategory#taxon warns and returns #category' do+ product_category = create(:classification)+ expect(Spree::Deprecation).to receive(:warn).with(/#category/)+ expect(product_category.taxon).to eq(product_category.category)+ end++ it 'Spree::Store#taxons warns and returns #categories' do+ store = create(:store)+ expect(Spree::Deprecation).to receive(:warn).with(/#categories/)+ expect(store.taxons).to eq(store.categories)+ end+ end+end