mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-09 23:06:06 +00:00
Add not_master scope to Spree::Variant
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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).
|
||||
|
||||
Reference in New Issue
Block a user