JTL Import
This commit is contained in:
@@ -19,7 +19,7 @@ use App\Helper\Hiltes;
|
||||
)]
|
||||
class HiltesExportCommand extends Command
|
||||
{
|
||||
public function __construct(OrderRepository $orderRepository, LoggerInterface $logger)
|
||||
public function __construct(OrderRepository $orderRepository, LoggerInterface $logger, private Hiltes $hiltes)
|
||||
{
|
||||
$this->orderRepository = $orderRepository;
|
||||
$this->logger = $logger;
|
||||
@@ -48,21 +48,18 @@ class HiltesExportCommand extends Command
|
||||
|
||||
$io->info('Start Hiltes Export');
|
||||
|
||||
$hiltes = new Hiltes();
|
||||
|
||||
|
||||
$orders = $this->orderRepository->findAll();
|
||||
|
||||
dump($orders);
|
||||
|
||||
die();
|
||||
|
||||
foreach ($orders as $order) {
|
||||
$hiltes->addOrder($order);
|
||||
$this->hiltes->addOrder($order);
|
||||
}
|
||||
|
||||
|
||||
$hiltes->export('Test Test');
|
||||
$this->hiltes->export('Test Test');
|
||||
|
||||
|
||||
$io->success('Done!');
|
||||
|
||||
@@ -33,7 +33,7 @@ class Order
|
||||
#[ORM\Column]
|
||||
private array $data = [];
|
||||
|
||||
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
|
||||
#[ORM\Column(type: Types::DATETIME_MUTABLE, name: 'change_date', options: ['default' => 'CURRENT_TIMESTAMP'])]
|
||||
private ?\DateTimeInterface $changeDate = null;
|
||||
|
||||
public function getId(): ?int
|
||||
|
||||
@@ -20,14 +20,14 @@ class Product
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $gtin = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $shopwareId = null;
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $modellnr = null;
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $modellbez = null;
|
||||
// #[ORM\Column(length: 255)]
|
||||
// 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, name: 'change_date', options: ['default' => 'CURRENT_TIMESTAMP'])]
|
||||
private ?\DateTimeInterface $updateTime = null;
|
||||
|
||||
|
||||
@@ -47,40 +47,40 @@ class Product
|
||||
|
||||
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
|
||||
{
|
||||
return $this->shopwareId;
|
||||
}
|
||||
|
||||
public function setShopwareId(string $shopwareId): self
|
||||
{
|
||||
$this->shopwareId = $shopwareId;
|
||||
|
||||
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
|
||||
// {
|
||||
// return $this->shopwareId;
|
||||
// }
|
||||
//
|
||||
// public function setShopwareId(string $shopwareId): self
|
||||
// {
|
||||
// $this->shopwareId = $shopwareId;
|
||||
//
|
||||
// return $this;
|
||||
// }
|
||||
|
||||
public function getUpdateTime(): ?\DateTimeInterface
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@ class Stock
|
||||
#[ORM\ManyToOne(inversedBy: 'stocks')]
|
||||
private ?Warehouse $warehouse = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
|
||||
#[ORM\Column(type: Types::DATETIME_MUTABLE, name: 'change_date', options: ['default' => 'CURRENT_TIMESTAMP'])]
|
||||
private ?\DateTimeInterface $update_time = null;
|
||||
|
||||
|
||||
@@ -123,4 +123,4 @@ class Stock
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ class HiltesImport
|
||||
{
|
||||
$finder = Finder::create();
|
||||
$finder
|
||||
->in($this->currentDirPath.'/hiltes/h2c/')
|
||||
->in($this->currentDirPath.'/hiltes/')
|
||||
->depth(0);
|
||||
#->filter(static function (SplFileInfo $file) {
|
||||
# return $file->isDir() || \preg_match('/\.(php|json)$/', $file->getPathname());
|
||||
@@ -168,12 +168,13 @@ class HiltesImport
|
||||
* @return void
|
||||
*/
|
||||
protected function saveData(Array $arr){
|
||||
#dump($arr);
|
||||
dump($arr);
|
||||
#*** 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]);
|
||||
#filiale;etikettnr;menge;
|
||||
$prodId = $this->checkProduct($arr[1]);
|
||||
#*** 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()];
|
||||
@@ -231,13 +232,11 @@ class HiltesImport
|
||||
if(empty($this->cachedWarehouseIds[$wareHouseName])){
|
||||
#*** Check
|
||||
$warehouse2 = $this->warehouseRepository->findOneBy(['id'=> (int)$wareHouseName]);
|
||||
//dump($warehouse2);
|
||||
if(empty($warehouse2)){
|
||||
$warehouse = new Warehouse();
|
||||
$warehouse->setId((int)$wareHouseName);
|
||||
$warehouse->setName($wareHouseName);
|
||||
#
|
||||
|
||||
$this->warehouseRepository->save($warehouse,true);
|
||||
|
||||
$this->cachedWarehouseIds[$wareHouseName] = $warehouse;
|
||||
@@ -260,18 +259,19 @@ class HiltesImport
|
||||
* @param string $modellBez
|
||||
* @return false|int|mixed|null
|
||||
*/
|
||||
private function checkProduct(string $gtin,string $modellNr,string $modellBez){
|
||||
private function checkProduct(string $gtin){
|
||||
#*** WEnn keine geCached Id Vorhanden
|
||||
if(empty($this->cachedProdIds[$gtin])){
|
||||
#*** Check
|
||||
dump($gtin);
|
||||
$prod2 = $this->productRepository->findOneBy(['gtin'=> $gtin]);
|
||||
#dump($warehouse2);
|
||||
dump($prod2);
|
||||
if(empty($prod2)){
|
||||
$prod = new Product();
|
||||
$prod->setGtin($gtin);
|
||||
$prod->setModellNr($modellNr);
|
||||
$prod->setModellBez($modellBez);
|
||||
$prod->setShopwareId("");
|
||||
// $prod->setModellNr($modellNr);
|
||||
// $prod->setModellBez($modellBez);
|
||||
// $prod->setShopwareId("");
|
||||
#
|
||||
$this->cachedProdIds[$gtin] = $this->productRepository->save($prod,true);
|
||||
#*****************
|
||||
@@ -286,6 +286,4 @@ class HiltesImport
|
||||
return $this->cachedProdIds[$gtin];
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -23,7 +23,7 @@ class StockRepository extends ServiceEntityRepository
|
||||
|
||||
public function save(Stock $entity, bool $flush = false): void
|
||||
{
|
||||
$entity->setUpdateTime(new \DateTime());
|
||||
//$entity->setUpdateTime(new \DateTime());
|
||||
|
||||
$this->getEntityManager()->persist($entity);
|
||||
|
||||
@@ -65,4 +65,4 @@ class StockRepository extends ServiceEntityRepository
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user