From a4c7dbc3295a5c09bdf6a2dcf55e5d7a7d087b45 Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Fri, 6 Mar 2020 12:30:13 +0000 Subject: [PATCH] Add comment to better explain why this scope is not simply using joins(:product) --- app/models/spree/line_item_decorator.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/models/spree/line_item_decorator.rb b/app/models/spree/line_item_decorator.rb index 2526f6670a..71e768c42d 100644 --- a/app/models/spree/line_item_decorator.rb +++ b/app/models/spree/line_item_decorator.rb @@ -46,6 +46,9 @@ Spree::LineItem.class_eval do where('order_cycles.id = ?', order_cycle) } + # Here we are simply joining the line item to its variant and product + # We do this with SQL to avoid the default scopes, + # and with that, include deleted variants and deleted products scope :supplied_by_any, lambda { |enterprises| joins("LEFT OUTER JOIN spree_variants ON spree_line_items.variant_id = spree_variants.id