Eager-load variant data for overridable products

Cuts query count and page load time in half for this endpoint.
This commit is contained in:
Matt-Yorkley
2020-04-07 14:21:09 +02:00
parent e0e2c32d9f
commit 64c66ddedc

View File

@@ -121,6 +121,7 @@ module Api
def paged_products_for_producers(producers)
Spree::Product.scoped.
merge(product_scope).
includes(variants: [:product, :default_price, :stock_items]).
where(supplier_id: producers).
by_producer.by_name.
ransack(params[:q]).result.