new importfiles
This commit is contained in:
parent
9bf0994b25
commit
48230c73a6
@ -8,13 +8,13 @@
|
||||
<jdbc-url>jdbc:mysql://127.0.0.1:3306</jdbc-url>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
<data-source source="LOCAL" name="DDEV" uuid="b6d8fd7a-dc7c-4d77-a130-438821ee9c9c">
|
||||
<data-source source="LOCAL" name="DDEV" uuid="096edb5d-73f9-4ef4-b462-f3f8e939a139">
|
||||
<driver-ref>mariadb</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<configured-by-url>true</configured-by-url>
|
||||
<remarks>DDEV generated data source</remarks>
|
||||
<jdbc-driver>org.mariadb.jdbc.Driver</jdbc-driver>
|
||||
<jdbc-url>jdbc:mariadb://127.0.0.1:64102/db?user=db&password=db</jdbc-url>
|
||||
<jdbc-url>jdbc:mariadb://127.0.0.1:32836/db?user=db&password=db</jdbc-url>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
</component>
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user