Merge branch 'master' of https://gitbase.de/OrangeJungle/CdsConnector
This commit is contained in:
17
README.md
17
README.md
@@ -18,15 +18,30 @@ Installiere Abhängigkeiten
|
|||||||
Starte MySQL-Server:
|
Starte MySQL-Server:
|
||||||
> docker compose up
|
> docker compose up
|
||||||
|
|
||||||
Erstelle Datenbank
|
Erstelle Datenbank (nicht die Tabellen)
|
||||||
> bin/console doctrine:database:create
|
> bin/console doctrine:database:create
|
||||||
>
|
>
|
||||||
|
|
||||||
Erstelle Tabellen
|
Erstelle Tabellen
|
||||||
> bin/console doctrine:migrations:migrate
|
> bin/console doctrine:migrations:migrate
|
||||||
|
|
||||||
|
Erstellen der Tabellen
|
||||||
|
> bin/console doctrine:migrations:migrate
|
||||||
|
|
||||||
|
Update der Datenbank
|
||||||
|
> bin/console doctrine:migrations:execute
|
||||||
|
|
||||||
Starte Server
|
Starte Server
|
||||||
> make dev-server
|
> make dev-server
|
||||||
|
|
||||||
API-Übersicht
|
API-Übersicht
|
||||||
> https://127.0.0.1:8000/api
|
> https://127.0.0.1:8000/api
|
||||||
|
|
||||||
|
Update Symphony
|
||||||
|
> composer update
|
||||||
|
|
||||||
|
# Benutzen
|
||||||
|
--------------
|
||||||
|
|
||||||
|
Hiltes Import
|
||||||
|
> bin/console hiltes:import
|
||||||
@@ -21,18 +21,18 @@ final class Version20230202141118 extends AbstractMigration
|
|||||||
{
|
{
|
||||||
// this up() migration is auto-generated, please modify it to your needs
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
$this->addSql('CREATE TABLE `order` (id INT AUTO_INCREMENT NOT NULL, order_id VARCHAR(255) NOT NULL, status INT NOT NULL, data LONGTEXT NOT NULL COMMENT \'(DC2Type:json)\', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
$this->addSql('CREATE TABLE `order` (id INT AUTO_INCREMENT NOT NULL, order_id VARCHAR(255) NOT NULL, status INT NOT NULL, data LONGTEXT NOT NULL COMMENT \'(DC2Type:json)\', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||||
$this->addSql('CREATE TABLE product (id INT AUTO_INCREMENT NOT NULL, stock_id INT DEFAULT NULL, gtin VARCHAR(255) NOT NULL, shopware_id VARCHAR(255) NOT NULL, update_time DATETIME NOT NULL, UNIQUE INDEX UNIQ_D34A04ADDCD6110 (stock_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
$this->addSql('CREATE TABLE product (id INT AUTO_INCREMENT NOT NULL, gtin VARCHAR(255) NOT NULL, shopware_id VARCHAR(255) DEFAULT NULL, modellnr VARCHAR(255) NOT NULL, modellbez VARCHAR(255) NOT NULL, update_time DATETIME NOT NULL,PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||||
$this->addSql('CREATE TABLE settings (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, value VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
$this->addSql('CREATE TABLE settings (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, value VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||||
$this->addSql('CREATE TABLE stock (id INT AUTO_INCREMENT NOT NULL, warehouse_id INT DEFAULT NULL, instock INT NOT NULL, INDEX IDX_4B3656605080ECDE (warehouse_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
$this->addSql('CREATE TABLE stock (id INT AUTO_INCREMENT NOT NULL, product_id INT DEFAULT NULL, warehouse_id INT DEFAULT NULL, instock INT NOT NULL, INDEX IDX_4B3656605080ECDE (warehouse_id), INDEX IDX_4B3656605080ECFF (product_id),UNIQUE INDEX UNIQ_D34A04ADDCD6110 (warehouse_id,product_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||||
$this->addSql('CREATE TABLE warehouse (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, prio INT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
$this->addSql('CREATE TABLE warehouse (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, prio INT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||||
$this->addSql('ALTER TABLE product ADD CONSTRAINT FK_D34A04ADDCD6110 FOREIGN KEY (stock_id) REFERENCES stock (id)');
|
# $this->addSql('ALTER TABLE product ADD CONSTRAINT FK_D34A04ADDCD6110 FOREIGN KEY (stock_id) REFERENCES stock (id)');
|
||||||
$this->addSql('ALTER TABLE stock ADD CONSTRAINT FK_4B3656605080ECDE FOREIGN KEY (warehouse_id) REFERENCES warehouse (id)');
|
$this->addSql('ALTER TABLE stock ADD CONSTRAINT FK_4B3656605080ECDE FOREIGN KEY (warehouse_id) REFERENCES warehouse (id)');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down(Schema $schema): void
|
public function down(Schema $schema): void
|
||||||
{
|
{
|
||||||
// this down() migration is auto-generated, please modify it to your needs
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
$this->addSql('ALTER TABLE product DROP FOREIGN KEY FK_D34A04ADDCD6110');
|
# $this->addSql('ALTER TABLE product DROP FOREIGN KEY FK_D34A04ADDCD6110');
|
||||||
$this->addSql('ALTER TABLE stock DROP FOREIGN KEY FK_4B3656605080ECDE');
|
$this->addSql('ALTER TABLE stock DROP FOREIGN KEY FK_4B3656605080ECDE');
|
||||||
$this->addSql('DROP TABLE `order`');
|
$this->addSql('DROP TABLE `order`');
|
||||||
$this->addSql('DROP TABLE product');
|
$this->addSql('DROP TABLE product');
|
||||||
|
|||||||
31
migrations/Version20230223121613.php
Normal file
31
migrations/Version20230223121613.php
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20230223121613 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('ALTER TABLE stock ADD update_time DATETIME DEFAULT NULL');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('ALTER TABLE stock DROP update_time');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -57,7 +57,7 @@ class HiltesImportCommand extends Command
|
|||||||
/**
|
/**
|
||||||
* @var HiltesImport
|
* @var HiltesImport
|
||||||
*/
|
*/
|
||||||
$hiltesImport = new HiltesImport($this->productRepository,$this->logger);
|
$hiltesImport = new HiltesImport($this->productRepository,$this->warehouseRepository,$this->stockRepository,$this->logger);
|
||||||
|
|
||||||
|
|
||||||
$r = $hiltesImport->startImport();
|
$r = $hiltesImport->startImport();
|
||||||
|
|||||||
@@ -21,12 +21,14 @@ class Product
|
|||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
#[ORM\Column(length: 255)]
|
||||||
private ?string $shopwareId = null;
|
private ?string $shopwareId = null;
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private ?string $modellnr = null;
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private ?string $modellbez = null;
|
||||||
|
|
||||||
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
|
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
|
||||||
private ?\DateTimeInterface $updateTime = null;
|
private ?\DateTimeInterface $updateTime = null;
|
||||||
|
|
||||||
#[ORM\OneToOne(inversedBy: 'product', cascade: ['persist', 'remove'])]
|
|
||||||
private ?Stock $stock = null;
|
|
||||||
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
{
|
{
|
||||||
@@ -44,6 +46,28 @@ class Product
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
public function getModellNr(): ?string
|
||||||
|
{
|
||||||
|
return $this->modellnr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setModellNr(string $modellnr): self
|
||||||
|
{
|
||||||
|
$this->modellnr = $modellnr;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
public function getModellBez(): ?string
|
||||||
|
{
|
||||||
|
return $this->modellbez;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setModellBez(string $modellbez): self
|
||||||
|
{
|
||||||
|
$this->modellbez = $modellbez;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function getShopwareId(): ?string
|
public function getShopwareId(): ?string
|
||||||
{
|
{
|
||||||
@@ -69,15 +93,4 @@ class Product
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStock(): ?Stock
|
|
||||||
{
|
|
||||||
return $this->stock;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setStock(?Stock $stock): self
|
|
||||||
{
|
|
||||||
$this->stock = $stock;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,17 @@
|
|||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
use App\Repository\StockRepository;
|
use App\Repository\StockRepository;
|
||||||
|
#use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Types\Types;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: StockRepository::class)]
|
#[ORM\Entity(repositoryClass: StockRepository::class)]
|
||||||
|
#[ORM\UniqueEntity(['warehouse_id', 'product_id'])]
|
||||||
|
#[ORM\UniqueConstraint(
|
||||||
|
name: 'UNIQ_D34A04ADDCD6110',
|
||||||
|
columns: ['warehouse_id', 'product_id']
|
||||||
|
)]
|
||||||
class Stock
|
class Stock
|
||||||
{
|
{
|
||||||
#[ORM\Id]
|
#[ORM\Id]
|
||||||
@@ -15,17 +23,26 @@ class Stock
|
|||||||
|
|
||||||
#[ORM\Column]
|
#[ORM\Column]
|
||||||
private ?int $instock = null;
|
private ?int $instock = null;
|
||||||
|
#[ORM\Column]
|
||||||
#[ORM\OneToOne(mappedBy: 'stock', cascade: ['persist', 'remove'])]
|
private ?int $product_id = null;
|
||||||
private ?Product $product = null;
|
|
||||||
|
|
||||||
#[ORM\ManyToOne(inversedBy: 'stocks')]
|
#[ORM\ManyToOne(inversedBy: 'stocks')]
|
||||||
private ?Warehouse $warehouse = null;
|
private ?Warehouse $warehouse = null;
|
||||||
|
|
||||||
|
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
|
||||||
|
private ?\DateTimeInterface $update_time = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
{
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
public function setId(int $id): ?self
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function getInstock(): ?int
|
public function getInstock(): ?int
|
||||||
{
|
{
|
||||||
@@ -38,6 +55,28 @@ class Stock
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
public function getProductId(): ?int
|
||||||
|
{
|
||||||
|
return $this->product_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setProductId(int $product_id): self
|
||||||
|
{
|
||||||
|
$this->product_id = $product_id;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
public function getWarehouseId(): ?int
|
||||||
|
{
|
||||||
|
return $this->warehouse_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setWarehouseId(int $warehouse_id): self
|
||||||
|
{
|
||||||
|
$this->warehouse_id = $warehouse_id;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function getProduct(): ?Product
|
public function getProduct(): ?Product
|
||||||
{
|
{
|
||||||
@@ -72,4 +111,16 @@ class Stock
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getUpdateTime(): ?\DateTimeInterface
|
||||||
|
{
|
||||||
|
return $this->update_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUpdateTime(?\DateTimeInterface $update_time): self
|
||||||
|
{
|
||||||
|
$this->update_time = $update_time;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,11 @@ class Warehouse
|
|||||||
{
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
public function setId(int $id): self
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function getName(): ?string
|
public function getName(): ?string
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,20 +7,28 @@ use App\Entity\Product;
|
|||||||
use App\Entity\Stock;
|
use App\Entity\Stock;
|
||||||
use App\Entity\Warehouse;
|
use App\Entity\Warehouse;
|
||||||
use App\Repository\ProductRepository;
|
use App\Repository\ProductRepository;
|
||||||
|
use App\Repository\StockRepository;
|
||||||
|
use App\Repository\WarehouseRepository;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Component\Finder\Finder;
|
use Symfony\Component\Finder\Finder;
|
||||||
|
|
||||||
class HiltesImport
|
class HiltesImport
|
||||||
{
|
{
|
||||||
private $productRepository;
|
private $productRepository;
|
||||||
|
private $stockRepository;
|
||||||
private $warehouseRepository;
|
private $warehouseRepository;
|
||||||
private $logger;
|
private $logger;
|
||||||
protected $currentDirPath;
|
protected $currentDirPath;
|
||||||
|
protected $cachedWarehouseIds;
|
||||||
|
private $cachedProdIds;
|
||||||
|
private $cachedStockIds;
|
||||||
protected $arrData = array();
|
protected $arrData = array();
|
||||||
|
|
||||||
public function __construct(ProductRepository $productRepository, LoggerInterface $logger)
|
public function __construct(ProductRepository $productRepository,WarehouseRepository $warehouseRepository,StockRepository $stockRepository, LoggerInterface $logger)
|
||||||
{
|
{
|
||||||
$this->productRepository = $productRepository;
|
$this->productRepository = $productRepository;
|
||||||
|
$this->warehouseRepository = $warehouseRepository;
|
||||||
|
$this->stockRepository = $stockRepository;
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
|
|
||||||
$this->currentDirPath = getcwd();
|
$this->currentDirPath = getcwd();
|
||||||
@@ -34,6 +42,8 @@ class HiltesImport
|
|||||||
{
|
{
|
||||||
#*** Holt alle Dateien
|
#*** Holt alle Dateien
|
||||||
if($this->getFiles()){
|
if($this->getFiles()){
|
||||||
|
#*** Holt Alle Stocks und setzt ein Array **************
|
||||||
|
$this->getStocks();
|
||||||
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'])){
|
||||||
@@ -46,7 +56,7 @@ class HiltesImport
|
|||||||
}else
|
}else
|
||||||
return array('success'=>1,'text'=>'No Files');
|
return array('success'=>1,'text'=>'No Files');
|
||||||
}else
|
}else
|
||||||
return array('error'=>1,'text'=>'Error in getFiles');
|
return array('error'=>1,'text'=>'Error in getFiles or no file WS.FERTIG');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,10 +71,14 @@ class HiltesImport
|
|||||||
#->filter(static function (SplFileInfo $file) {
|
#->filter(static function (SplFileInfo $file) {
|
||||||
# return $file->isDir() || \preg_match('/\.(php|json)$/', $file->getPathname());
|
# return $file->isDir() || \preg_match('/\.(php|json)$/', $file->getPathname());
|
||||||
#});
|
#});
|
||||||
|
$hasFoundFertigFile = false;
|
||||||
if ($finder->hasResults()) {
|
if ($finder->hasResults()) {
|
||||||
|
#dump($finder);
|
||||||
dump($finder);
|
|
||||||
foreach ($finder as $file) {
|
foreach ($finder as $file) {
|
||||||
|
if($file->getRelativePathname()=='WS.FERTIG'){
|
||||||
|
$hasFoundFertigFile = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$this->arrData['orgFiles']['data'][] = array(
|
$this->arrData['orgFiles']['data'][] = array(
|
||||||
'realPath' => $file->getRealPath(),
|
'realPath' => $file->getRealPath(),
|
||||||
'fileSize' => $file->getFileInfo()->getSize(),
|
'fileSize' => $file->getFileInfo()->getSize(),
|
||||||
@@ -75,16 +89,25 @@ class HiltesImport
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return $hasFoundFertigFile;
|
||||||
|
}
|
||||||
|
protected function getStocks()
|
||||||
|
{
|
||||||
|
$r = $this->stockRepository->findAll();
|
||||||
|
foreach ($r as $v) {
|
||||||
|
$this->cachedStockIds[$v->getProductId()][$v->getWarehouse()->getId()] = $v;
|
||||||
|
}
|
||||||
|
#dd($this->cachedStockIds);
|
||||||
}
|
}
|
||||||
protected function loadFiles($srcFile,$size)
|
protected function loadFiles($srcFile,$size)
|
||||||
{
|
{
|
||||||
|
#*** Check File ****
|
||||||
|
#dd($srcFile);
|
||||||
$file = new \SplFileObject($srcFile);
|
$file = new \SplFileObject($srcFile);
|
||||||
dump($file->getRealPath());
|
#dump($file->getRealPath());
|
||||||
|
|
||||||
$this->logger->info('Starte Import von ' . $file->getRealPath());
|
$this->logger->info('Starte Import von ' . $file->getRealPath());
|
||||||
|
dump('Starte Import von ' . $file->getRealPath());
|
||||||
$c = 0;
|
$c = 0;
|
||||||
while (!$file->eof()) {
|
while (!$file->eof()) {
|
||||||
// Header überspringen
|
// Header überspringen
|
||||||
@@ -119,52 +142,6 @@ class HiltesImport
|
|||||||
#*** Leerzeichen löschen bei den einzelnen Einträgen **********
|
#*** Leerzeichen löschen bei den einzelnen Einträgen **********
|
||||||
$this->trimArray($arr);
|
$this->trimArray($arr);
|
||||||
#***
|
#***
|
||||||
// $arr[0] = strtolower($arr[0]);
|
|
||||||
// switch ($arr[0]){
|
|
||||||
// case 'datei': # Datei
|
|
||||||
// $this->saveInfoDatei($arr);
|
|
||||||
// break;
|
|
||||||
// case 'filiale': # Filiale
|
|
||||||
// #$this->saveInfoFiliale($arr);
|
|
||||||
// break;
|
|
||||||
// case 'land': # Länder
|
|
||||||
// $this->saveInfoLand($arr);
|
|
||||||
// break;
|
|
||||||
// case 'hwg': # Hauptwarengruppe
|
|
||||||
// #$this->saveInfoHauptWarenGruppe($arr);
|
|
||||||
// break;
|
|
||||||
// case 'wg': # Warengruppe
|
|
||||||
// #$this->saveInfoWarenGruppe($arr);
|
|
||||||
// break;
|
|
||||||
// case 'anrede': # Anrede
|
|
||||||
// #$this->saveInfoAnrede($arr);
|
|
||||||
// break;
|
|
||||||
// case 'lieferant': # Lieferant
|
|
||||||
// #$this->saveInfoLieferant($arr);
|
|
||||||
// break;
|
|
||||||
// case 'farb': # Farbcodierung
|
|
||||||
// #$this->saveInfoFarbCodierung($arr);
|
|
||||||
// break;
|
|
||||||
// case 'nlart': # NachlassArt
|
|
||||||
// #$this->saveInfoNachlassArt($arr);
|
|
||||||
// break;
|
|
||||||
// case 'kollektion': # Kollektion
|
|
||||||
// #$this->saveInfoKollektion($arr);
|
|
||||||
// break;
|
|
||||||
// case 'bestand': # Bestand
|
|
||||||
// #$this->saveInfoBestand($arr);
|
|
||||||
// break;
|
|
||||||
// case 'merkmale': # Made In XXXX = Land
|
|
||||||
// #$this->saveInfoMerkmale($arr);
|
|
||||||
// break;
|
|
||||||
// case 'material': # MAterial
|
|
||||||
// #$this->saveInfoMaterial($arr);
|
|
||||||
// break;
|
|
||||||
// default: #
|
|
||||||
// dump('!!!!! KEIN DEFINIERTER ANFANG "'.$arr[0].'" !!!!!!!!!');
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
|
|
||||||
$this->saveData($arr);
|
$this->saveData($arr);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -182,28 +159,27 @@ class HiltesImport
|
|||||||
*/
|
*/
|
||||||
protected function saveData(Array $arr){
|
protected function saveData(Array $arr){
|
||||||
#dump($arr);
|
#dump($arr);
|
||||||
$prod = new Product();
|
#*** Speichert und/oder Holt WareHouse ab
|
||||||
|
$wareHouse = $this->checkWareHouseName($arr[0]);
|
||||||
|
#*** PRodukt wird angelegt oder geholt ****
|
||||||
|
#filiale;etikettnr;menge;modellnr;modellbez
|
||||||
|
$prodId = $this->checkProduct($arr[1],$arr[3],$arr[4]);
|
||||||
|
#*** Ermitteln ob schon ein ID vorhadnen für ProdId und WareHouseId
|
||||||
|
if(!empty($wareHouse) && !empty($this->cachedStockIds[$prodId][$wareHouse->getId()])){
|
||||||
|
$stock = $this->cachedStockIds[$prodId][$wareHouse->getId()];
|
||||||
|
#dd('JAAAAA');
|
||||||
|
}else{
|
||||||
$stock = new Stock();
|
$stock = new Stock();
|
||||||
|
$stock->setProductId($prodId);
|
||||||
|
$stock->setWarehouse($wareHouse);
|
||||||
|
}
|
||||||
|
#dd('CHCEK');
|
||||||
$stock->setInstock((int)$arr[2]);
|
$stock->setInstock((int)$arr[2]);
|
||||||
|
#$stock->setWarehouseId($wareHouseId);
|
||||||
|
#dump($stock);
|
||||||
|
$this->stockRepository->save($stock,true);
|
||||||
|
|
||||||
$warehouse = new Warehouse();
|
#dd($stock);
|
||||||
$warehouse->setName($arr[0]);
|
|
||||||
// $stock->setWarehouse($warehouse);
|
|
||||||
|
|
||||||
#menge;
|
|
||||||
$prod->setStock($stock);
|
|
||||||
|
|
||||||
#eanzuIdent;
|
|
||||||
$prod->setGtin($arr[13]);
|
|
||||||
|
|
||||||
$prod->setShopwareId("");
|
|
||||||
|
|
||||||
|
|
||||||
// dump($prod);
|
|
||||||
|
|
||||||
$this->productRepository->save($prod,true);
|
|
||||||
|
|
||||||
//$stock->setStock((int)$arr[2]);
|
//$stock->setStock((int)$arr[2]);
|
||||||
|
|
||||||
#filiale;
|
#filiale;
|
||||||
@@ -236,27 +212,52 @@ class HiltesImport
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private function checkWareHouseName(string $wareHouseName){
|
||||||
* @param $id
|
#*** WEnn keine geCached Id Vorhanden
|
||||||
* @return mixed
|
$warehouse2 = false;
|
||||||
*/
|
if(empty($this->cachedWarehouseIds[$wareHouseName])){
|
||||||
private function getWarehouseId($id){
|
#*** Check
|
||||||
$warehouse = $this->warehouseRepository->findOneBy(array('id'=>$id));
|
$warehouse2 = $this->warehouseRepository->findOneBy(['id'=> (int)$wareHouseName]);
|
||||||
if($warehouse instanceof Warehouse){
|
#dump($warehouse2);
|
||||||
return $warehouse->getId();
|
if(empty($warehouse2)){
|
||||||
}else{
|
|
||||||
$warehouse = new Warehouse();
|
$warehouse = new Warehouse();
|
||||||
|
$warehouse->setId((int)$wareHouseName);
|
||||||
|
$warehouse->setName($wareHouseName);
|
||||||
$warehouse->setPriority(0);
|
#
|
||||||
$warehouse->setId($this->warehouseRepository->add($warehouse, true));
|
$this->warehouseRepository->save($warehouse,true);
|
||||||
|
#*****************
|
||||||
dump($warehouse);
|
$warehouse2 = $this->warehouseRepository->findOneBy(['id'=> (int)$wareHouseName]);
|
||||||
|
#dump($warehouse2);
|
||||||
|
|
||||||
|
|
||||||
return $warehouse;
|
|
||||||
}
|
}
|
||||||
|
$this->cachedWarehouseIds[$wareHouseName] = $warehouse2;
|
||||||
|
}
|
||||||
|
if(!empty($this->cachedWarehouseIds[$wareHouseName]))
|
||||||
|
return $this->cachedWarehouseIds[$wareHouseName];
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
private function checkProduct(string $gtin,string $modellNr,string $modellBez){
|
||||||
|
#*** WEnn keine geCached Id Vorhanden
|
||||||
|
if(empty($this->cachedProdIds[$gtin])){
|
||||||
|
#*** Check
|
||||||
|
$prod2 = $this->productRepository->findOneBy(['gtin'=> $gtin]);
|
||||||
|
#dump($warehouse2);
|
||||||
|
if(empty($prod2)){
|
||||||
|
$prod = new Product();
|
||||||
|
$prod->setGtin($gtin);
|
||||||
|
$prod->setModellNr($modellNr);
|
||||||
|
$prod->setModellBez($modellBez);
|
||||||
|
$prod->setShopwareId("");
|
||||||
|
#
|
||||||
|
$this->productRepository->save($prod,true);
|
||||||
|
#*****************
|
||||||
|
$prod2 = $this->productRepository->findOneBy(['gtin'=> $gtin]);
|
||||||
|
#dump($warehouse2);
|
||||||
|
}
|
||||||
|
$this->cachedProdIds[$gtin] = $prod2->getId();
|
||||||
|
}
|
||||||
|
if(!empty($this->cachedProdIds[$gtin]))
|
||||||
|
return $this->cachedProdIds[$gtin];
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ class StockRepository extends ServiceEntityRepository
|
|||||||
|
|
||||||
public function save(Stock $entity, bool $flush = false): void
|
public function save(Stock $entity, bool $flush = false): void
|
||||||
{
|
{
|
||||||
|
$entity->setUpdateTime(new \DateTime());
|
||||||
|
|
||||||
$this->getEntityManager()->persist($entity);
|
$this->getEntityManager()->persist($entity);
|
||||||
|
|
||||||
if ($flush) {
|
if ($flush) {
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ class WarehouseRepository extends ServiceEntityRepository
|
|||||||
|
|
||||||
public function save(Warehouse $entity, bool $flush = false): void
|
public function save(Warehouse $entity, bool $flush = false): void
|
||||||
{
|
{
|
||||||
|
$entity->setPrio(0);
|
||||||
$this->getEntityManager()->persist($entity);
|
$this->getEntityManager()->persist($entity);
|
||||||
|
|
||||||
if ($flush) {
|
if ($flush) {
|
||||||
|
|||||||
Reference in New Issue
Block a user