Skip to content

Commit

Permalink
Avoid N+1 queries when fetching products in SolidusAdmin
Browse files Browse the repository at this point in the history
Co-Authored-By: Rainer Dema <[email protected]>
  • Loading branch information
elia and rainerdema committed Dec 13, 2023
1 parent 9f940cd commit 2b857af
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions admin/app/controllers/solidus_admin/products_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ class ProductsController < SolidusAdmin::BaseController

def index
products = apply_search_to(
Spree::Product.order(created_at: :desc, id: :desc),
Spree::Product.includes(:master, variants: :default_price),
param: :q,
)

set_page_and_extract_portion_from(products)
set_page_and_extract_portion_from(
products,
ordered_by: { updated_at: :desc, id: :desc },
)

respond_to do |format|
format.html { render component('products/index').new(page: @page) }
Expand Down

0 comments on commit 2b857af

Please sign in to comment.