From 1829e9112e17c72f58b1b332291090621868aa3b Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Wed, 1 Apr 2020 04:30:08 +0000 Subject: [PATCH] Add error_logging in case of duplicate SAP battery. #371 --- src/Command/ImportSAPBatteryCommand.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Command/ImportSAPBatteryCommand.php b/src/Command/ImportSAPBatteryCommand.php index fcd54f7d..8ea53a1d 100644 --- a/src/Command/ImportSAPBatteryCommand.php +++ b/src/Command/ImportSAPBatteryCommand.php @@ -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();