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.

Reduce the number of SQL on PDP to generate breadcrumbs

Damian Legawiec02829acda0d5
diff --git a/storefront/app/helpers/spree/products_helper.rb b/storefront/app/helpers/spree/products_helper.rb
index ede0805063..22e6b16320 100644
--- a/storefront/app/helpers/spree/products_helper.rb
+++ b/storefront/app/helpers/spree/products_helper.rb
@@ -146,9 +146,10 @@ module Spree
end
def product_breadcrumb_taxons(product)
- return Spree::Taxon.none if product.taxons.empty?
+ return Spree::Taxon.none if product.main_taxon.blank?
- product.main_taxon.self_and_ancestors.where.not(depth: 0)
+ # using find_all as we already iterate over the taxons in #product_json_ld_breadcrumbs
+ product.main_taxon.self_and_ancestors.find_all { |taxon| taxon.depth != 0 }
end
def product_list_json_ld_elements(product_slugs)