Sha256: 1ed608cda04d48ad7beb74150027f76b702d58d3a36b10a6413441ff9e87feec

Contents?: true

Size: 1.61 KB

Versions: 28

Compression:

Stored size: 1.61 KB

Contents

module Workarea
  module Search
    class Storefront
      class Product
        module Categories
          extend ActiveSupport::Concern

          # TODO remove these in v3.6
          class_methods do
            Workarea.deprecation.deprecate_methods(
              self,
              add_category: 'Use `Search::Storefront::CategoryQuery.new(category).create` instead',
              delete_category: 'Use `Search::Storefront::CategoryQuery.new(category).delete` instead',
              find_categories: 'Use `Workarea::Search::Storefront::CategoryQuery.find_by_product` instead'
            )

            def add_category(category)
              CategoryQuery.new(category).create
            end

            def delete_category(category_id)
              CategoryQuery.new(category_id).delete
            end

            def find_categories(product)
              CategoryQuery.find_by_product(product)
            end
          end

          # A list of the {Catalog::Category} IDs that the product was featured
          # in. Used for adding featured products to category listings in
          # addition to the products that match on rules.
          #
          # @return [Array<String>]
          #
          def category_id
            categorization.manual
          end

          # List of categories for the product.
          #
          # @return [Array<Workarea::Categorization>]
          #
          def categorization
            return Workarea::Categorization.new if options[:skip_categorization]
            @categorization ||= Workarea::Categorization.new(model)
          end
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
workarea-core-3.5.27 app/models/workarea/search/storefront/product/categories.rb
workarea-core-3.5.26 app/models/workarea/search/storefront/product/categories.rb
workarea-core-3.5.25 app/models/workarea/search/storefront/product/categories.rb
workarea-core-3.5.23 app/models/workarea/search/storefront/product/categories.rb
workarea-core-3.5.22 app/models/workarea/search/storefront/product/categories.rb
workarea-core-3.5.21 app/models/workarea/search/storefront/product/categories.rb
workarea-core-3.5.20 app/models/workarea/search/storefront/product/categories.rb
workarea-core-3.5.19 app/models/workarea/search/storefront/product/categories.rb
workarea-core-3.5.18 app/models/workarea/search/storefront/product/categories.rb
workarea-core-3.5.17 app/models/workarea/search/storefront/product/categories.rb
workarea-core-3.5.16 app/models/workarea/search/storefront/product/categories.rb
workarea-core-3.5.15 app/models/workarea/search/storefront/product/categories.rb
workarea-core-3.5.14 app/models/workarea/search/storefront/product/categories.rb
workarea-core-3.5.13 app/models/workarea/search/storefront/product/categories.rb
workarea-core-3.5.12 app/models/workarea/search/storefront/product/categories.rb
workarea-core-3.5.11 app/models/workarea/search/storefront/product/categories.rb
workarea-core-3.5.10 app/models/workarea/search/storefront/product/categories.rb
workarea-core-3.5.9 app/models/workarea/search/storefront/product/categories.rb
workarea-core-3.5.8 app/models/workarea/search/storefront/product/categories.rb
workarea-core-3.5.7 app/models/workarea/search/storefront/product/categories.rb