From 42a0a973ba6f98dd8aa8518f4bf48ef1f48848d4 Mon Sep 17 00:00:00 2001 From: SarvarKhalimov Date: Sun, 13 Feb 2022 18:28:21 +0500 Subject: [PATCH] Fix product import on existing, empty unit_type and variant_unit --- app/models/product_import/entry_validator.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/models/product_import/entry_validator.rb b/app/models/product_import/entry_validator.rb index 9710cb37dc..f3babe9c11 100644 --- a/app/models/product_import/entry_validator.rb +++ b/app/models/product_import/entry_validator.rb @@ -73,11 +73,13 @@ module ProductImport 'variant_unit_scale', 'primary_taxon_id') ) new_variant.save - if entry.attributes['on_demand'].present? - new_variant.on_demand = entry.attributes['on_demand'] - end - if entry.attributes['on_hand'].present? - new_variant.on_hand = entry.attributes['on_hand'] + if entry.attributes['unit_type'].present? || entry.attributes['variant_unit_name'].present? + if entry.attributes['on_demand'].present? + new_variant.on_demand = entry.attributes['on_demand'] + end + if entry.attributes['on_hand'].present? + new_variant.on_hand = entry.attributes['on_hand'] + end end new_variant.product_id = product_id