when importing first do a lookup by code before creating a new item
This commit is contained in:
@@ -185,9 +185,11 @@ def import_single_item(row, index, logger)
|
|||||||
succes = true
|
succes = true
|
||||||
begin
|
begin
|
||||||
lookup = get_column_lookup
|
lookup = get_column_lookup
|
||||||
item = Item.new
|
code = row[lookup[:code]]
|
||||||
|
|
||||||
|
item = (Item.find_by code: code) || Item.new
|
||||||
item.name = row[lookup[:name_on_ribica]]
|
item.name = row[lookup[:name_on_ribica]]
|
||||||
item.code = row[lookup[:code]]
|
item.code = code
|
||||||
item.current_input_price = row[lookup[:current_input_price]] || 11.00
|
item.current_input_price = row[lookup[:current_input_price]] || 11.00
|
||||||
item.list_price = row[lookup[:list_price]] || 12.00
|
item.list_price = row[lookup[:list_price]] || 12.00
|
||||||
item.units_in_pack = row[lookup[:units_in_pack]]
|
item.units_in_pack = row[lookup[:units_in_pack]]
|
||||||
@@ -252,6 +254,7 @@ def do_import(validate_only)
|
|||||||
|
|
||||||
if validate_only || should_rollback
|
if validate_only || should_rollback
|
||||||
if should_rollback
|
if should_rollback
|
||||||
|
puts "Import failed, please check the import log file for error details."
|
||||||
logger.info "Rolling back because of errors"
|
logger.info "Rolling back because of errors"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user