Skip to content

armgit / spree

Public Imported from GitHub
0

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.

Remove unused argument. Use Platform API.

Matthew Kennedy82d90e5c5e36
diff --git a/api/app/controllers/spree/api/v2/platform/products_controller.rb b/api/app/controllers/spree/api/v2/platform/products_controller.rb
index aa4cd6ec1a..ab70dd5106 100644
--- a/api/app/controllers/spree/api/v2/platform/products_controller.rb
+++ b/api/app/controllers/spree/api/v2/platform/products_controller.rb
@@ -2,37 +2,9 @@ module Spree
module Api
module V2
module Platform
- class ProductsController < ::Spree::Api::V2::ResourceController
+ class ProductsController < ResourceController
private
- def sorted_collection
- collection_sorter.new(collection, current_currency, params, allowed_sort_attributes).call
- end
-
- def collection
- @collection ||= collection_finder.new(scope: scope, params: params, current_currency: current_currency).execute
- end
-
- def resource
- @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
diff --git a/api/app/controllers/spree/api/v2/platform/taxons_controller.rb b/api/app/controllers/spree/api/v2/platform/taxons_controller.rb
index b748a9b148..3146c271fe 100644
--- a/api/app/controllers/spree/api/v2/platform/taxons_controller.rb
+++ b/api/app/controllers/spree/api/v2/platform/taxons_controller.rb
@@ -2,29 +2,9 @@ module Spree
module Api
module V2
module Platform
- class TaxonsController < ::Spree::Api::V2::ResourceController
+ class TaxonsController < ResourceController
private
- def collection_serializer
- Spree::Api::Dependencies.storefront_taxon_serializer.constantize
- end
-
- def resource_serializer
- Spree::Api::Dependencies.storefront_taxon_serializer.constantize
- end
-
- def collection_finder
- Spree::Api::Dependencies.storefront_taxon_finder.constantize
- end
-
- def paginated_collection
- @paginated_collection ||= collection_paginator.new(collection, params).call
- end
-
- def resource
- @resource ||= scope.find_by(permalink: params[:id]) || scope.find(params[:id])
- end
-
def model_class
Spree::Taxon
end
diff --git a/api/app/serializers/spree/api/v2/platform/image_serializer.rb b/api/app/serializers/spree/api/v2/platform/image_serializer.rb
new file mode 100644
index 0000000000..51b8c45101
--- /dev/null
+++ b/api/app/serializers/spree/api/v2/platform/image_serializer.rb
@@ -0,0 +1,13 @@
+module Spree
+ module Api
+ module V2
+ module Platform
+ class ImageSerializer < BaseSerializer
+ set_type :image
+
+ attributes :viewable_type, :viewable_id, :styles
+ end
+ end
+ end
+ end
+end
diff --git a/api/app/serializers/spree/api/v2/platform/product_property_serializer.rb b/api/app/serializers/spree/api/v2/platform/product_property_serializer.rb
new file mode 100644
index 0000000000..fc472edf41
--- /dev/null
+++ b/api/app/serializers/spree/api/v2/platform/product_property_serializer.rb
@@ -0,0 +1,21 @@
+module Spree
+ module Api
+ module V2
+ module Platform
+ class ProductPropertySerializer < BaseSerializer
+ set_type :product_property
+
+ attribute :value
+
+ attribute :name do |product_property|
+ product_property.property_name
+ end
+
+ attribute :description do |product_property|
+ product_property.property_presentation
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/api/app/serializers/spree/api/v2/platform/variant_serializer.rb b/api/app/serializers/spree/api/v2/platform/variant_serializer.rb
new file mode 100644
index 0000000000..746ade2eb1
--- /dev/null
+++ b/api/app/serializers/spree/api/v2/platform/variant_serializer.rb
@@ -0,0 +1,51 @@
+module Spree
+ module Api
+ module V2
+ module Platform
+ class VariantSerializer < BaseSerializer
+ include ::Spree::Api::V2::DisplayMoneyHelper
+
+ set_type :variant
+
+ attributes :sku, :weight, :height, :width, :depth, :is_master, :options_text
+
+ attribute :purchasable do |variant|
+ variant.purchasable?
+ end
+
+ attribute :in_stock do |variant|
+ variant.in_stock?
+ end
+
+ attribute :backorderable do |variant|
+ variant.backorderable?
+ end
+
+ attribute :currency do |_product, params|
+ params[:currency]
+ end
+
+ attribute :price do |product, params|
+ price(product, params[:currency])
+ end
+
+ attribute :display_price do |product, params|
+ display_price(product, params[:currency])
+ end
+
+ attribute :compare_at_price do |product, params|
+ compare_at_price(product, params[:currency])
+ end
+
+ attribute :display_compare_at_price do |product, params|
+ display_compare_at_price(product, params[:currency])
+ end
+
+ belongs_to :product
+ has_many :images
+ has_many :option_values
+ end
+ end
+ end
+ end
+end
diff --git a/backend/app/assets/javascripts/spree/backend/global/utils.es6 b/backend/app/assets/javascripts/spree/backend/global/utils.es6
index d9ee12d97f..5138088095 100644
--- a/backend/app/assets/javascripts/spree/backend/global/utils.es6
+++ b/backend/app/assets/javascripts/spree/backend/global/utils.es6
@@ -21,7 +21,7 @@ const populateSelectOptionsFromApi = function(params) {
createRequest(params, updateSelectSuccess, updateSelectError)
};
-const createRequest = function(params, succeed, fail, init) {
+const createRequest = function(params, succeed, fail) {
const targetElement = params.targetElement
const apiUrl = params.apiUrl
const returnAttribute = params.returnAttribute