new importfiles
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Marko 2023-04-04 10:24:02 +02:00
parent f484d000cf
commit 0579a62931
No known key found for this signature in database
2 changed files with 26 additions and 16 deletions

View File

@ -67,8 +67,8 @@ class HiltesImportCommand extends Command
$this->logger->error($r['text']);
return Command::FAILURE;
}else{
$pushStock = new SwPushStockCommand($this->stockRepository,$this->warehouseRepository,$this->logger);
$io->info('Start Hiltes Push Stock');
$pushStock = new SwPushStockCommand($this->productRepository,$this->logger);
$pushStock->execute($input,$output);
$io->success('Done.');

View File

@ -42,17 +42,19 @@ class HiltesImport
{
#*** Holt alle Dateien
if($this->getFiles()){
#*** Holt Alle Stocks und setzt ein Array **************
#*** Holt alle Stocks und setzt ein Array **************
$this->getStocks();
$count = 0;
if(!empty($this->arrData['orgFiles']['data']) && count($this->arrData['orgFiles']['data'])){
foreach ($this->arrData['orgFiles']['data'] as $file) {
if(is_file($file['realPath'])){
$this->loadFiles($file['realPath'],$file['fileSize']);
$count += $this->loadFiles($file['realPath'],$file['fileSize']);
}else{
return array('error'=>1,'text'=>'Error is_file('.$file['realPath'].')');
}
}
dump("Imported $count stocks");
}else
return array('success'=>1,'text'=>'No Files');
}else
@ -99,6 +101,12 @@ class HiltesImport
}
#dd($this->cachedStockIds);
}
/**
* @param $srcFile
* @param $size
* @return int
*/
protected function loadFiles($srcFile,$size)
{
#*** Check File ****
@ -110,22 +118,24 @@ class HiltesImport
dump('Starte Import von ' . $file->getRealPath());
$c = 0;
while (!$file->eof()) {
// Header überspringen
$c++;
#*** Convertiert die Zeile in UTF8
$data = iconv('ISO-8859-1','UTF-8',$file->fgets());
#*** Zerlegt die Zeile **********
//$data = $file->fgets();
if($c <= 1){ continue; }
#*** Convertiert die Zeile in UTF8
$data = iconv('ISO-8859-1','UTF-8',$file->fgets());
#*** Überspringt die erste Zeile
if($c == 0){
$c++;
continue;
}
#*** Speichert die Zeile
$this->switchSaveData($this->splitLine($data));
$c++;
}
// $em = $this->productRepository->getEntityManager();
// $em->flush();
dump($c . ' Datensätze importiert');
return $c;
}
protected function splitLine($str){
return str_getcsv($str,';','"');
@ -259,8 +269,8 @@ class HiltesImport
if(empty($prod2)){
$prod = new Product();
$prod->setGtin($gtin);
$prod->setModellNr(trim($modellNr));
$prod->setModellBez(trim($modellBez));
$prod->setModellNr($modellNr);
$prod->setModellBez($modellBez);
$prod->setShopwareId("");
#
$this->cachedProdIds[$gtin] = $this->productRepository->save($prod,true);