Add error_logging in case of duplicate SAP battery. #371

This commit is contained in:
Korina Cordero 2020-04-01 04:30:08 +00:00
parent 506505bff5
commit 1829e9112e

View file

@ -77,7 +77,7 @@ class ImportSAPBatteryCommand extends Command
// clean up fields
$clean_brand = trim($fields[0]);
$clean_sku = trim($fields[1]);
$clean_sku = strtoupper(trim($fields[1]));
$clean_size = trim($fields[2]);
$output->writeln("Parsing $clean_sku...");
@ -110,11 +110,17 @@ class ImportSAPBatteryCommand extends Command
// create battery entry
$battery = new SAPBattery();
$battery->setID($clean_sku)
->setSize($size_hash[$clean_size])
->setBrand($brand_hash[$clean_brand]);
->setSize($this->batt_size_hash[$clean_size])
->setBrand($this->batt_brand_hash[$clean_brand]);
$em->persist($battery);
}
else
{
// TODO: different batteries but same SKU: WCHD23BL-CPN00-LX
// how to process?
error_log('Battery with that sku already exists.');
}
}
$em->flush();