import hiltes
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Marko
2023-02-22 10:34:33 +01:00
parent 0c04e6da7c
commit fd02b0d410
8 changed files with 243 additions and 144 deletions

View File

@@ -7,16 +7,12 @@ use App\Entity\Product;
use App\Entity\Stock;
use App\Entity\Warehouse;
use App\Repository\ProductRepository;
use App\Repository\StockRepository;
use App\Repository\WarehouseRepository;
use Doctrine\ORM\EntityManager;
use Psr\Log\LoggerInterface;
use Symfony\Component\Finder\Finder;
class HiltesImport
{
private $productRepository;
private $stockRepository;
private $warehouseRepository;
private $logger;
protected $currentDirPath;
@@ -24,9 +20,6 @@ class HiltesImport
public function __construct(ProductRepository $productRepository, LoggerInterface $logger)
{
// $this->stockRepository = $stockRepository;
// $this->warehouseRepository = $warehouseRepository;
$this->productRepository = $productRepository;
$this->logger = $logger;
@@ -34,7 +27,9 @@ class HiltesImport
}
/**
* @return array|void
*/
public function startImport()
{
#*** Holt alle Dateien
@@ -44,6 +39,7 @@ class HiltesImport
if(is_file($file['realPath'])){
$this->loadFiles($file['realPath'],$file['fileSize']);
}else{
return array('error'=>1,'text'=>'Error is_file('.$file['realPath'].')');
}
}
@@ -52,6 +48,10 @@ class HiltesImport
}else
return array('error'=>1,'text'=>'Error in getFiles');
}
/**
* @return bool
*/
protected function getFiles()
{
$finder = Finder::create();
@@ -62,6 +62,8 @@ class HiltesImport
# return $file->isDir() || \preg_match('/\.(php|json)$/', $file->getPathname());
#});
if ($finder->hasResults()) {
dump($finder);
foreach ($finder as $file) {
$this->arrData['orgFiles']['data'][] = array(
'realPath' => $file->getRealPath(),
@@ -79,9 +81,8 @@ class HiltesImport
{
$file = new \SplFileObject($srcFile);
dump($file->getRealPath());
$this->logger->info('Starte Import von ' . $file->getRealPath());
$c = 0;
@@ -98,6 +99,9 @@ class HiltesImport
$this->switchSaveData($this->splitLine($data));
}
// $em = $this->productRepository->getEntityManager();
// $em->flush();
dump($c . ' Datensätze importiert');
}
protected function splitLine($str){
@@ -190,8 +194,8 @@ class HiltesImport
#menge;
$prod->setStock($stock);
#gtin;
$prod->setGtin($arr[1]);
#eanzuIdent;
$prod->setGtin($arr[13]);
$prod->setShopwareId("");