diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml
index 1b3c3e2..ef5c13b 100644
--- a/.idea/dataSources.xml
+++ b/.idea/dataSources.xml
@@ -8,13 +8,13 @@
jdbc:mysql://127.0.0.1:3306
$ProjectFileDir$
-
+
mariadb
true
true
DDEV generated data source
org.mariadb.jdbc.Driver
- jdbc:mariadb://127.0.0.1:64102/db?user=db&password=db
+ jdbc:mariadb://127.0.0.1:32836/db?user=db&password=db
$ProjectFileDir$
diff --git a/README.md b/README.md
index f146a08..3c370ae 100644
--- a/README.md
+++ b/README.md
@@ -19,15 +19,11 @@ Starte MySQL-Server:
> docker compose up
Erstelle Datenbank (nicht die Tabellen)
-> bin/console doctrine:database:create
->
+> bin/console doctrine:database:create
Erstelle Tabellen
> bin/console doctrine:migrations:migrate
-Erstellen der Tabellen
-> bin/console doctrine:migrations:migrate
-
Update der Datenbank
> bin/console doctrine:migrations:execute
diff --git a/src/Command/HiltesImportCommand.php b/src/Command/HiltesImportCommand.php
index fc453b4..e46d44d 100644
--- a/src/Command/HiltesImportCommand.php
+++ b/src/Command/HiltesImportCommand.php
@@ -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;
diff --git a/src/Helper/HiltesImport.php b/src/Helper/HiltesImport.php
index 817e2bf..9e64c48 100644
--- a/src/Helper/HiltesImport.php
+++ b/src/Helper/HiltesImport.php
@@ -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];
diff --git a/src/Repository/ProductRepository.php b/src/Repository/ProductRepository.php
index 42edb5b..2d14203 100644
--- a/src/Repository/ProductRepository.php
+++ b/src/Repository/ProductRepository.php
@@ -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
diff --git a/src/Repository/WarehouseRepository.php b/src/Repository/WarehouseRepository.php
index 1bbe4b6..9f45889 100644
--- a/src/Repository/WarehouseRepository.php
+++ b/src/Repository/WarehouseRepository.php
@@ -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