From 2bac76ff402834a125dca3695392a3dfa600ddd1 Mon Sep 17 00:00:00 2001 From: Gaetan Craig-Riou Date: Mon, 17 Jun 2024 15:52:18 +1000 Subject: [PATCH] Refactor #products_relation Due to primary_taxon and supplier having moved to the variant, filtering by_producer and by_category with a custom order involves some complicated sql queries. So we moved the sorting logic from ProductsRenderer to OrderCycles::DistributedProductsService so we can keep the complicated SQL logic contained in one place --- app/services/order_cycles/distributed_products_service.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/services/order_cycles/distributed_products_service.rb b/app/services/order_cycles/distributed_products_service.rb index e47ec7a4e3..648a6a6697 100644 --- a/app/services/order_cycles/distributed_products_service.rb +++ b/app/services/order_cycles/distributed_products_service.rb @@ -71,8 +71,8 @@ module OrderCycles distributor.preferred_shopfront_product_sorting_method end - def supplier_property_join(query) - query.joins(" + def supplier_property_join + @query = @query.joins(" JOIN enterprises ON enterprises.id = first_variant.supplier_id LEFT OUTER JOIN producer_properties ON producer_properties.producer_id = enterprises.id ")