spree/spree · warning

Spree::Taxons::AddProducts is deprecated and will be removed

Error message

Spree::Taxons::AddProducts is deprecated and will be removed in Spree 6.1. Use Spree::Categories::AddProducts instead.

What it means

The 6.0 taxon→category rename: Spree::Taxons::AddProducts is a deprecated shim that warns and delegates to Spree::Categories::AddProducts.call(categories:, products:), which bulk-inserts product-category join rows with incremental positions. The old taxons: keyword keeps working through the shim; removed in 6.1.

Source

Thrown at spree/core/app/services/spree/taxons/add_products.rb:13

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
end

View on GitHub (pinned to 06bf66a868)

Solutions

  1. Call Spree::Categories::AddProducts.call(categories: [category], products: products) — same bulk behavior and positions.
  2. Rename surrounding taxon vocabulary to category (Spree::Taxon is an alias for Spree::Category in 6.0) so the code reads consistently.
  3. Sweep for 'Taxons::' service references — AutoMatchTaxons (error 233) and RegenerateProducts (error 239) belong to the same family.
  4. Confirm with deprecations raised that no shim is still exercised.

Example fix

# before
Spree::Taxons::AddProducts.call(taxons: [taxon], products: [product])

# after
Spree::Categories::AddProducts.call(categories: [category], products: [product])
Defensive patterns

Strategy: validation

Validate before calling

if defined?(Spree::Categories::AddProducts)
  Spree::Categories::AddProducts.call(categories: [taxon], products: products)
else
  Spree::Taxons::AddProducts.call(taxons: [taxon], products: products)
end

Type guard

# @return [Boolean] true when the category-named bulk adder exists
def spree_categories_add_products?
  defined?(Spree::Categories::AddProducts)
end

Prevention

When it happens

Trigger: Spree::Taxons::AddProducts.call(taxons: [taxon], products: products) — admin bulk-categorization actions, imports and seeds written against the pre-6.0 namespace.

Common situations: Catalog tooling upgraded to 6.0; CSV import pipelines assigning products to taxons; extensions managing category membership.

Related errors


AI-assisted analysis of spree/spree@06bf66a868 (2026-08-21). Data as JSON: /api/errors/5daf640ef12bd17d. Report an issue: GitHub.