mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Make product import set correct VO stock settings
This commit is contained in:
@@ -323,8 +323,10 @@ module ProductImport
|
||||
|
||||
def create_inventory_item(entry, existing_variant)
|
||||
variant_override = find_or_initialize_variant_override(entry, existing_variant)
|
||||
variant_override.assign_attributes(count_on_hand: entry.on_hand, import_date: @import_time)
|
||||
check_on_hand_nil(entry, variant_override)
|
||||
|
||||
check_variant_override_stock_settings(entry, variant_override)
|
||||
|
||||
variant_override.assign_attributes(import_date: @import_time)
|
||||
variant_override.assign_attributes(entry.attributes.slice('price', 'on_demand'))
|
||||
|
||||
variant_override
|
||||
@@ -358,5 +360,11 @@ module ProductImport
|
||||
object.count_on_hand = 0 if object.respond_to?(:count_on_hand)
|
||||
entry.on_hand_nil = true
|
||||
end
|
||||
|
||||
def check_variant_override_stock_settings(entry, object)
|
||||
object.count_on_hand = entry.on_hand.presence
|
||||
object.on_demand = object.count_on_hand.blank? if entry.on_demand.blank?
|
||||
entry.on_hand_nil = object.count_on_hand.blank?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user