From a503b5e2d0b1a703f1bc5527a45241d7bb7776e4 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley Date: Mon, 19 Mar 2018 15:47:44 +0000 Subject: [PATCH] Add not_master scope to Spree::Variant --- app/models/product_import/entry_processor.rb | 6 +++--- app/models/spree/variant_decorator.rb | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/models/product_import/entry_processor.rb b/app/models/product_import/entry_processor.rb index 9be32f7e98..509a21fd43 100644 --- a/app/models/product_import/entry_processor.rb +++ b/app/models/product_import/entry_processor.rb @@ -42,10 +42,10 @@ module ProductImport VariantOverride.where('variant_overrides.hub_id IN (?)', supplier_id).count else Spree::Variant. + not_deleted. + not_master. joins(:product). - where('spree_products.supplier_id IN (?) - AND spree_variants.is_master = false - AND spree_variants.deleted_at IS NULL', supplier_id). + where('spree_products.supplier_id IN (?)', supplier_id). count end diff --git a/app/models/spree/variant_decorator.rb b/app/models/spree/variant_decorator.rb index c0a90500cf..2947efc282 100644 --- a/app/models/spree/variant_decorator.rb +++ b/app/models/spree/variant_decorator.rb @@ -32,6 +32,8 @@ Spree::Variant.class_eval do scope :with_order_cycles_inner, joins(exchanges: :order_cycle) scope :not_deleted, where(deleted_at: nil) + scope :not_master, where(is_master: false) + scope :in_stock, where('spree_variants.count_on_hand > 0 OR spree_variants.on_demand=?', true) scope :in_order_cycle, lambda { |order_cycle| with_order_cycles_inner. merge(Exchange.outgoing).