Simplify backorderable priority SQL query in product sorting concern

This commit is contained in:
Ahmed Ejaz
2025-09-15 12:03:04 +05:00
parent 1987f0b667
commit dffcd446fd

View File

@@ -13,7 +13,7 @@ module ProductSortByStocks
)")
@backorderable_priority_sql = Arel.sql("(
SELECT CASE WHEN BOOL_OR(si.backorderable) = true THEN 1 ELSE 0 END
SELECT BOOL_OR(si.backorderable)
FROM spree_variants v
JOIN spree_stock_items si ON si.variant_id = v.id
WHERE v.product_id = spree_products.id