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.

find product by slug or id, CC fix

Matthew Kennedyc770cc470002
diff --git a/api/app/controllers/spree/api/v2/storefront/cms_pages_controller.rb b/api/app/controllers/spree/api/v2/storefront/cms_pages_controller.rb
index a66e7454b2..ad5798670c 100644
--- a/api/app/controllers/spree/api/v2/storefront/cms_pages_controller.rb
+++ b/api/app/controllers/spree/api/v2/storefront/cms_pages_controller.rb
@@ -10,7 +10,7 @@ module Spree
end
def resource
- @resource ||= scope.friendly.find(params[:slug])
+ @resource ||= scope.find_by(slug: params[:id]) || scope.find(params[:id])
end
def resource_serializer
diff --git a/api/config/routes.rb b/api/config/routes.rb
index 89964240e8..9c11da3b34 100644
--- a/api/config/routes.rb
+++ b/api/config/routes.rb
@@ -167,8 +167,7 @@ Spree::Core::Engine.add_routes do
resources :menus, only: %i[index]
get '/menus/:location', to: 'menus#show', as: :menu
- resources :cms_pages, only: %i[index], path: '/pages'
- get '/cms_pages/:slug', to: 'cms_pages#show', as: :page
+ resources :cms_pages, only: %i[index show], path: '/pages'
end
namespace :platform do
diff --git a/frontend/app/controllers/spree/home_controller.rb b/frontend/app/controllers/spree/home_controller.rb
index ceaae922f1..a28e4070cb 100644
--- a/frontend/app/controllers/spree/home_controller.rb
+++ b/frontend/app/controllers/spree/home_controller.rb
@@ -30,7 +30,7 @@ module Spree
def last_modified_index
page_last_modified = @cms_home_page&.maximum(:updated_at)&.utc if @cms_home_page.respond_to?(:maximum)
- current_store_last_modified =current_store.updated_at.utc
+ current_store_last_modified = current_store.updated_at.utc
[page_last_modified, current_store_last_modified].compact.max
end