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.

Only fetch Products from the Current Store in Storefront API Products endpoint

Damian Legawiec691af784d070
diff --git a/api/app/controllers/spree/api/v2/storefront/products_controller.rb b/api/app/controllers/spree/api/v2/storefront/products_controller.rb
index 183bff2f75..51d1814ef3 100644
--- a/api/app/controllers/spree/api/v2/storefront/products_controller.rb
+++ b/api/app/controllers/spree/api/v2/storefront/products_controller.rb
@@ -3,7 +3,7 @@ module Spree
module V2
module Storefront
class ProductsController < ::Spree::Api::V2::ResourceController
- private
+ protected
def sorted_collection
collection_sorter.new(collection, current_currency, params, allowed_sort_attributes).call
@@ -37,6 +37,10 @@ module Spree
Spree::Product
end
+ def scope
+ current_store.products.accessible_by(current_ability, :show).includes(scope_includes)
+ end
+
def scope_includes
{
master: :default_price,