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.

Use `storefront_products_scope` everywhere

Damian Legawiece2b4bb39af3b
diff --git a/storefront/app/controllers/spree/products_controller.rb b/storefront/app/controllers/spree/products_controller.rb
index 575ce6a0f8..7d102fc9f5 100644
--- a/storefront/app/controllers/spree/products_controller.rb
+++ b/storefront/app/controllers/spree/products_controller.rb
@@ -23,7 +23,7 @@ module Spree
load_product
# An interesting thing is that since we're querying the translations table (in the multi_search),
# when using not default locale, our related products are different for different locales.
- @products = current_store.products.active(current_currency).where.not(id: @product.id).
+ @products = storefront_products_scope.where.not(id: @product.id).
multi_search(@product.name).includes(storefront_products_includes).
limit(@section.preferred_max_products_to_show)
end
diff --git a/storefront/app/controllers/spree/search_controller.rb b/storefront/app/controllers/spree/search_controller.rb
index 1c5b7c29c7..8f6923bf1c 100644
--- a/storefront/app/controllers/spree/search_controller.rb
+++ b/storefront/app/controllers/spree/search_controller.rb
@@ -13,7 +13,7 @@ module Spree
@taxons = []
if query.present? && query.length >= Spree::Storefront::Config.search_min_query_length
- products_scope = current_store.products.active(current_currency).multi_search(query)
+ products_scope = storefront_products_scope.multi_search(query)
@products = products_scope.includes(storefront_products_includes)
@taxons = current_store.taxons.search_by_name(query)
end
diff --git a/storefront/app/views/spree/seo/sitemap.xml.erb b/storefront/app/views/spree/seo/sitemap.xml.erb
index 2f75030bbe..df81608ce5 100644
--- a/storefront/app/views/spree/seo/sitemap.xml.erb
+++ b/storefront/app/views/spree/seo/sitemap.xml.erb
@@ -12,8 +12,8 @@
<% end %>
<% end %>
- <% cache [current_store.products, current_currency] do %>
- <% current_store.products.active(current_currency).find_each do |product| %>
+ <% cache [storefront_products_scope, current_currency] do %>
+ <% storefront_products_scope.find_each do |product| %>
<url>
<loc><%= spree_storefront_resource_url(product) %></loc>
<lastmod><%= product.updated_at.strftime('%Y-%m-%d') %></lastmod>