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.6 app/models/workarea/search/storefront/product/categories.rb
workarea-core-3.5.5 app/models/workarea/search/storefront/product/categories.rb
workarea-core-3.5.4 app/models/workarea/search/storefront/product/categories.rb
workarea-core-3.5.3 app/models/workarea/search/storefront/product/categories.rb
workarea-core-3.5.2 app/models/workarea/search/storefront/product/categories.rb
workarea-core-3.5.1 app/models/workarea/search/storefront/product/categories.rb
workarea-core-3.5.0 app/models/workarea/search/storefront/product/categories.rb
workarea-core-3.5.0.beta.1 app/models/workarea/search/storefront/product/categories.rb