Sha256: 924e050b6f855087f9ac0286832563d8690f696f433f47df709e012afddf027f

Contents?: true

Size: 1.5 KB

Versions: 12

Compression:

Stored size: 1.5 KB

Contents

module Spree
  module Api
    module V2
      module Storefront
        class ProductsController < ::Spree::Api::V2::ResourceController
          private

          def sorted_collection
            collection_sorter.new(collection, current_currency, params, allowed_sort_attributes).call
          end

          def collection
            collection_finder.new(scope: scope, params: params, current_currency: current_currency).execute
          end

          def resource
            scope.find_by(slug: params[:id]) || scope.find(params[:id])
          end

          def collection_sorter
            Spree::Api::Dependencies.storefront_products_sorter.constantize
          end

          def collection_finder
            Spree::Api::Dependencies.storefront_products_finder.constantize
          end

          def collection_serializer
            Spree::Api::Dependencies.storefront_product_serializer.constantize
          end

          def resource_serializer
            Spree::Api::Dependencies.storefront_product_serializer.constantize
          end

          def model_class
            Spree::Product
          end

          def scope_includes
            {
              master: :default_price,
              variants: [],
              variant_images: [],
              taxons: [],
              product_properties: :property,
              option_types: :option_values,
              variants_including_master: %i[default_price option_values]
            }
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
spree_api-4.2.7 app/controllers/spree/api/v2/storefront/products_controller.rb
spree_api-4.2.6 app/controllers/spree/api/v2/storefront/products_controller.rb
spree_api-4.2.5 app/controllers/spree/api/v2/storefront/products_controller.rb
spree_api-4.2.4 app/controllers/spree/api/v2/storefront/products_controller.rb
spree_api-4.2.3.1 app/controllers/spree/api/v2/storefront/products_controller.rb
spree_api-4.2.3 app/controllers/spree/api/v2/storefront/products_controller.rb
spree_api-4.2.2 app/controllers/spree/api/v2/storefront/products_controller.rb
spree_api-4.2.1 app/controllers/spree/api/v2/storefront/products_controller.rb
spree_api-4.2.0 app/controllers/spree/api/v2/storefront/products_controller.rb
spree_api-4.2.0.rc5 app/controllers/spree/api/v2/storefront/products_controller.rb
spree_api-4.2.0.rc4 app/controllers/spree/api/v2/storefront/products_controller.rb
spree_api-4.2.0.rc3 app/controllers/spree/api/v2/storefront/products_controller.rb