Add not_master scope to Spree::Variant

This commit is contained in:
Matt-Yorkley
2018-03-19 15:47:44 +00:00
parent 91521dc2b0
commit a503b5e2d0
2 changed files with 5 additions and 3 deletions

View File

@@ -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

View File

@@ -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).