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