new importfiles
This commit is contained in:
@@ -62,7 +62,7 @@ class HiltesImportCommand extends Command
|
||||
|
||||
$r = $hiltesImport->startImport();
|
||||
|
||||
if($r['error']){
|
||||
if(isset($r['error'])){
|
||||
$io->error($r['text']);
|
||||
$this->logger->error($r['text']);
|
||||
return Command::FAILURE;
|
||||
|
||||
@@ -113,10 +113,10 @@ class HiltesImport
|
||||
// Header überspringen
|
||||
$c++;
|
||||
#*** Convertiert die Zeile in UTF8
|
||||
//$str = iconv('ISO-8859-1','UTF-8',$file->fgets());
|
||||
$data = iconv('ISO-8859-1','UTF-8',$file->fgets());
|
||||
|
||||
#*** Zerlegt die Zeile **********
|
||||
$data = $file->fgets();
|
||||
//$data = $file->fgets();
|
||||
if($c <= 1){ continue; }
|
||||
|
||||
$this->switchSaveData($this->splitLine($data));
|
||||
@@ -212,29 +212,44 @@ class HiltesImport
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $wareHouseName
|
||||
* @return Warehouse|false|int|mixed|null
|
||||
*/
|
||||
private function checkWareHouseName(string $wareHouseName){
|
||||
#*** WEnn keine geCached Id Vorhanden
|
||||
$warehouse2 = false;
|
||||
if(empty($this->cachedWarehouseIds[$wareHouseName])){
|
||||
#*** Check
|
||||
$warehouse2 = $this->warehouseRepository->findOneBy(['id'=> (int)$wareHouseName]);
|
||||
#dump($warehouse2);
|
||||
//dump($warehouse2);
|
||||
if(empty($warehouse2)){
|
||||
$warehouse = new Warehouse();
|
||||
$warehouse->setId((int)$wareHouseName);
|
||||
$warehouse->setName($wareHouseName);
|
||||
#
|
||||
$this->warehouseRepository->save($warehouse,true);
|
||||
|
||||
$this->warehouseRepository->save($warehouse,true);
|
||||
|
||||
$this->cachedWarehouseIds[$wareHouseName] = $warehouse;
|
||||
#*****************
|
||||
$warehouse2 = $this->warehouseRepository->findOneBy(['id'=> (int)$wareHouseName]);
|
||||
#$warehouse2 = $this->warehouseRepository->findOneBy(['id'=> (int)$wareHouseName]);
|
||||
#dump($warehouse2);
|
||||
}
|
||||
$this->cachedWarehouseIds[$wareHouseName] = $warehouse2;
|
||||
}else{
|
||||
$this->cachedWarehouseIds[$wareHouseName] = $warehouse2;
|
||||
}
|
||||
|
||||
}
|
||||
if(!empty($this->cachedWarehouseIds[$wareHouseName]))
|
||||
return $this->cachedWarehouseIds[$wareHouseName];
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $gtin
|
||||
* @param string $modellNr
|
||||
* @param string $modellBez
|
||||
* @return false|int|mixed|null
|
||||
*/
|
||||
private function checkProduct(string $gtin,string $modellNr,string $modellBez){
|
||||
#*** WEnn keine geCached Id Vorhanden
|
||||
if(empty($this->cachedProdIds[$gtin])){
|
||||
@@ -244,16 +259,18 @@ class HiltesImport
|
||||
if(empty($prod2)){
|
||||
$prod = new Product();
|
||||
$prod->setGtin($gtin);
|
||||
$prod->setModellNr($modellNr);
|
||||
$prod->setModellBez($modellBez);
|
||||
$prod->setModellNr(trim($modellNr));
|
||||
$prod->setModellBez(trim($modellBez));
|
||||
$prod->setShopwareId("");
|
||||
#
|
||||
$this->productRepository->save($prod,true);
|
||||
$this->cachedProdIds[$gtin] = $this->productRepository->save($prod,true);
|
||||
#*****************
|
||||
$prod2 = $this->productRepository->findOneBy(['gtin'=> $gtin]);
|
||||
//$prod2 = $this->productRepository->findOneBy(['gtin'=> $gtin]);
|
||||
#dump($warehouse2);
|
||||
}
|
||||
$this->cachedProdIds[$gtin] = $prod2->getId();
|
||||
}else{
|
||||
$this->cachedProdIds[$gtin] = $prod2->getId();
|
||||
}
|
||||
|
||||
}
|
||||
if(!empty($this->cachedProdIds[$gtin]))
|
||||
return $this->cachedProdIds[$gtin];
|
||||
|
||||
@@ -21,7 +21,7 @@ class ProductRepository extends ServiceEntityRepository
|
||||
parent::__construct($registry, Product::class);
|
||||
}
|
||||
|
||||
public function save(Product $entity, bool $flush = false): void
|
||||
public function save(Product $entity, bool $flush = false): ?int
|
||||
{
|
||||
|
||||
$entity->setUpdateTime(new \DateTime());
|
||||
@@ -31,6 +31,8 @@ class ProductRepository extends ServiceEntityRepository
|
||||
if ($flush) {
|
||||
$this->getEntityManager()->flush();
|
||||
}
|
||||
|
||||
return $entity->getId();
|
||||
}
|
||||
|
||||
public function remove(Product $entity, bool $flush = false): void
|
||||
|
||||
@@ -21,7 +21,7 @@ class WarehouseRepository extends ServiceEntityRepository
|
||||
parent::__construct($registry, Warehouse::class);
|
||||
}
|
||||
|
||||
public function save(Warehouse $entity, bool $flush = false): void
|
||||
public function save(Warehouse $entity, bool $flush = false): ?int
|
||||
{
|
||||
$entity->setPrio(0);
|
||||
$this->getEntityManager()->persist($entity);
|
||||
@@ -29,6 +29,8 @@ class WarehouseRepository extends ServiceEntityRepository
|
||||
if ($flush) {
|
||||
$this->getEntityManager()->flush();
|
||||
}
|
||||
|
||||
return $entity->getId();
|
||||
}
|
||||
|
||||
public function remove(Warehouse $entity, bool $flush = false): void
|
||||
|
||||
Reference in New Issue
Block a user