import hiltes
This commit is contained in:
parent
991dd95e9d
commit
0c04e6da7c
@ -1,43 +0,0 @@
|
|||||||
<?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 Version20230119141248 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('CREATE TABLE hls_country (id INT AUTO_INCREMENT NOT NULL, short_name VARCHAR(255) NOT NULL, short_iso VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
|
||||||
$this->addSql('CREATE TABLE orders (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 products (id INT AUTO_INCREMENT NOT NULL, shopware_id CHAR(36) DEFAULT NULL COMMENT \'(DC2Type:guid)\', 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_id INT DEFAULT NULL, prod_id_id INT DEFAULT NULL, gtin VARCHAR(255) NOT NULL, stock INT NOT NULL, update_time DATETIME DEFAULT NULL, INDEX IDX_4B365660FE25E29A (warehouse_id_id), INDEX IDX_4B365660F91A0F34 (prod_id_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, priority INT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
|
||||||
$this->addSql('ALTER TABLE stock ADD CONSTRAINT FK_4B365660FE25E29A FOREIGN KEY (warehouse_id_id) REFERENCES warehouse (id)');
|
|
||||||
$this->addSql('ALTER TABLE stock ADD CONSTRAINT FK_4B365660F91A0F34 FOREIGN KEY (prod_id_id) REFERENCES products (id)');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function down(Schema $schema): void
|
|
||||||
{
|
|
||||||
// this down() migration is auto-generated, please modify it to your needs
|
|
||||||
$this->addSql('ALTER TABLE stock DROP FOREIGN KEY FK_4B365660FE25E29A');
|
|
||||||
$this->addSql('ALTER TABLE stock DROP FOREIGN KEY FK_4B365660F91A0F34');
|
|
||||||
$this->addSql('DROP TABLE hls_country');
|
|
||||||
$this->addSql('DROP TABLE orders');
|
|
||||||
$this->addSql('DROP TABLE products');
|
|
||||||
$this->addSql('DROP TABLE stock');
|
|
||||||
$this->addSql('DROP TABLE warehouse');
|
|
||||||
}
|
|
||||||
}
|
|
43
migrations/Version20230202141118.php
Normal file
43
migrations/Version20230202141118.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?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 Version20230202141118 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('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 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 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 stock ADD CONSTRAINT FK_4B3656605080ECDE FOREIGN KEY (warehouse_id) REFERENCES warehouse (id)');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// 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 stock DROP FOREIGN KEY FK_4B3656605080ECDE');
|
||||||
|
$this->addSql('DROP TABLE `order`');
|
||||||
|
$this->addSql('DROP TABLE product');
|
||||||
|
$this->addSql('DROP TABLE settings');
|
||||||
|
$this->addSql('DROP TABLE stock');
|
||||||
|
$this->addSql('DROP TABLE warehouse');
|
||||||
|
}
|
||||||
|
}
|
100272
phpunit.phar
Normal file
100272
phpunit.phar
Normal file
File diff suppressed because one or more lines are too long
@ -3,6 +3,7 @@
|
|||||||
namespace App\Command;
|
namespace App\Command;
|
||||||
|
|
||||||
use App\Helper\HiltesImport;
|
use App\Helper\HiltesImport;
|
||||||
|
use App\Repository\ProductRepository;
|
||||||
use App\Repository\StockRepository;
|
use App\Repository\StockRepository;
|
||||||
use App\Repository\WarehouseRepository;
|
use App\Repository\WarehouseRepository;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
@ -24,9 +25,16 @@ class HiltesImportCommand extends Command
|
|||||||
{
|
{
|
||||||
private $stockRepository;
|
private $stockRepository;
|
||||||
private $warehouseRepository;
|
private $warehouseRepository;
|
||||||
|
private $productRepository;
|
||||||
private $logger;
|
private $logger;
|
||||||
public function __construct(StockRepository $stockRepository, WarehouseRepository $warehouseRepository, LoggerInterface $logger)
|
public function __construct(
|
||||||
|
ProductRepository $productRepository,
|
||||||
|
StockRepository $stockRepository,
|
||||||
|
WarehouseRepository $warehouseRepository,
|
||||||
|
LoggerInterface $logger
|
||||||
|
)
|
||||||
{
|
{
|
||||||
|
$this->productRepository = $productRepository;
|
||||||
$this->stockRepository = $stockRepository;
|
$this->stockRepository = $stockRepository;
|
||||||
$this->warehouseRepository = $warehouseRepository;
|
$this->warehouseRepository = $warehouseRepository;
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
@ -43,16 +51,13 @@ class HiltesImportCommand extends Command
|
|||||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||||
{
|
{
|
||||||
$io = new SymfonyStyle($input, $output);
|
$io = new SymfonyStyle($input, $output);
|
||||||
$arg1 = $input->getArgument('arg1');
|
|
||||||
|
|
||||||
if ($arg1) {
|
$io->success('Start Hiltes Import');
|
||||||
$io->note(sprintf('You passed an argument: %s', $arg1));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var HiltesImport
|
* @var HiltesImport
|
||||||
*/
|
*/
|
||||||
$hiltesImport = new HiltesImport($this->stockRepository,$this->warehouseRepository,$this->logger);
|
$hiltesImport = new HiltesImport($this->productRepository,$this->logger);
|
||||||
$hiltesImport->startImport();
|
$hiltesImport->startImport();
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,12 +23,12 @@ class SwPushStockCommand extends Command
|
|||||||
private $stockRepository;
|
private $stockRepository;
|
||||||
private $logger;
|
private $logger;
|
||||||
|
|
||||||
public function __construct(StockRepository $stockRepository, LoggerInterface $logger)
|
// public function __construct(StockRepository $stockRepository, LoggerInterface $logger)
|
||||||
{
|
// {
|
||||||
$this->stockRepository = $stockRepository;
|
// $this->stockRepository = $stockRepository;
|
||||||
$this->logger = $logger;
|
// $this->logger = $logger;
|
||||||
parent::__construct();
|
// parent::__construct();
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
protected function configure(): void
|
protected function configure(): void
|
||||||
|
@ -1,65 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Entity;
|
|
||||||
|
|
||||||
use App\Repository\HlsCountryRepository;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: HlsCountryRepository::class)]
|
|
||||||
class HlsCountry
|
|
||||||
{
|
|
||||||
#[ORM\Id]
|
|
||||||
#[ORM\GeneratedValue]
|
|
||||||
#[ORM\Column]
|
|
||||||
private ?int $id = null;
|
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
|
||||||
private ?string $short_name = null;
|
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
|
||||||
private ?string $short_iso = null;
|
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
|
||||||
private ?string $name = null;
|
|
||||||
|
|
||||||
public function getId(): ?int
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getShortName(): ?string
|
|
||||||
{
|
|
||||||
return $this->short_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setShortName(string $short_name): self
|
|
||||||
{
|
|
||||||
$this->short_name = $short_name;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getShortIso(): ?string
|
|
||||||
{
|
|
||||||
return $this->short_iso;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setShortIso(string $short_iso): self
|
|
||||||
{
|
|
||||||
$this->short_iso = $short_iso;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getName(): ?string
|
|
||||||
{
|
|
||||||
return $this->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setName(string $name): self
|
|
||||||
{
|
|
||||||
$this->name = $name;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
|
68
src/Entity/Order.php
Normal file
68
src/Entity/Order.php
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity;
|
||||||
|
|
||||||
|
use ApiPlatform\Metadata\ApiResource;
|
||||||
|
use App\Repository\OrderRepository;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
#[ORM\Entity(repositoryClass: OrderRepository::class)]
|
||||||
|
#[ORM\Table(name: '`order`')]
|
||||||
|
#[ApiResource]
|
||||||
|
class Order
|
||||||
|
{
|
||||||
|
#[ORM\Id]
|
||||||
|
#[ORM\GeneratedValue]
|
||||||
|
#[ORM\Column]
|
||||||
|
private ?int $id = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private ?string $orderId = null;
|
||||||
|
|
||||||
|
#[ORM\Column]
|
||||||
|
private ?int $status = null;
|
||||||
|
|
||||||
|
#[ORM\Column]
|
||||||
|
private array $data = [];
|
||||||
|
|
||||||
|
public function getId(): ?int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getOrderId(): ?string
|
||||||
|
{
|
||||||
|
return $this->orderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setOrderId(string $orderId): self
|
||||||
|
{
|
||||||
|
$this->orderId = $orderId;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getStatus(): ?int
|
||||||
|
{
|
||||||
|
return $this->status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setStatus(int $status): self
|
||||||
|
{
|
||||||
|
$this->status = $status;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getData(): array
|
||||||
|
{
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setData(array $data): self
|
||||||
|
{
|
||||||
|
$this->data = $data;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
@ -1,78 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Entity;
|
|
||||||
|
|
||||||
use ApiPlatform\Core\Annotation\ApiProperty;
|
|
||||||
use App\Repository\OrdersRepository;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
use ApiPlatform\Core\Annotation\ApiResource;
|
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: OrdersRepository::class)]
|
|
||||||
#[ORM\HasLifecycleCallbacks]
|
|
||||||
#[ApiResource(
|
|
||||||
description: "Manage orders",
|
|
||||||
itemOperations: ["GET"],
|
|
||||||
normalizationContext: ["groups" => "read"]
|
|
||||||
)]
|
|
||||||
class Orders
|
|
||||||
{
|
|
||||||
#[ORM\Id]
|
|
||||||
#[ORM\GeneratedValue]
|
|
||||||
#[ORM\Column(type: 'integer')]
|
|
||||||
private $id;
|
|
||||||
|
|
||||||
/** Shopware Order ID */
|
|
||||||
#[ORM\Column(type: 'string', length: 255)]
|
|
||||||
#[Assert\NotBlank]
|
|
||||||
#[ApiProperty(example: "467e9804347c4071942c99b55b108142")]
|
|
||||||
#[Group("read")]
|
|
||||||
private $order_id;
|
|
||||||
|
|
||||||
#[ORM\Column(type: 'integer')]
|
|
||||||
#[ApiProperty(example: "1")]
|
|
||||||
private $status;
|
|
||||||
|
|
||||||
#[ORM\Column(type: 'json')]
|
|
||||||
#[ApiProperty(writable: false)]
|
|
||||||
private $data = [];
|
|
||||||
|
|
||||||
public function getId(): ?int
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getOrderId(): ?string
|
|
||||||
{
|
|
||||||
return $this->order_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setOrderId(string $order_id): self
|
|
||||||
{
|
|
||||||
$this->order_id = $order_id;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getStatus(): ?int
|
|
||||||
{
|
|
||||||
return $this->status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setStatus(int $status): self
|
|
||||||
{
|
|
||||||
$this->status = $status;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getData(): ?array
|
|
||||||
{
|
|
||||||
return $this->data;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#[ORM\PrePersist]
|
|
||||||
public function setData(array $data): self
|
|
||||||
{
|
|
||||||
$this->data = $data;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
|
83
src/Entity/Product.php
Normal file
83
src/Entity/Product.php
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity;
|
||||||
|
|
||||||
|
use ApiPlatform\Metadata\ApiResource;
|
||||||
|
use App\Repository\ProductRepository;
|
||||||
|
use Doctrine\DBAL\Types\Types;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
#[ORM\Entity(repositoryClass: ProductRepository::class)]
|
||||||
|
#[ApiResource]
|
||||||
|
class Product
|
||||||
|
{
|
||||||
|
#[ORM\Id]
|
||||||
|
#[ORM\GeneratedValue]
|
||||||
|
#[ORM\Column]
|
||||||
|
private ?int $id = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private ?string $gtin = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private ?string $shopwareId = null;
|
||||||
|
|
||||||
|
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
|
||||||
|
private ?\DateTimeInterface $updateTime = null;
|
||||||
|
|
||||||
|
#[ORM\OneToOne(inversedBy: 'product', cascade: ['persist', 'remove'])]
|
||||||
|
private ?Stock $stock = null;
|
||||||
|
|
||||||
|
public function getId(): ?int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getGtin(): ?string
|
||||||
|
{
|
||||||
|
return $this->gtin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setGtin(string $gtin): self
|
||||||
|
{
|
||||||
|
$this->gtin = $gtin;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getShopwareId(): ?string
|
||||||
|
{
|
||||||
|
return $this->shopwareId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setShopwareId(string $shopwareId): self
|
||||||
|
{
|
||||||
|
$this->shopwareId = $shopwareId;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUpdateTime(): ?\DateTimeInterface
|
||||||
|
{
|
||||||
|
return $this->updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUpdateTime(\DateTimeInterface $updateTime): self
|
||||||
|
{
|
||||||
|
$this->updateTime = $updateTime;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getStock(): ?Stock
|
||||||
|
{
|
||||||
|
return $this->stock;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setStock(?Stock $stock): self
|
||||||
|
{
|
||||||
|
$this->stock = $stock;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
@ -1,76 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Entity;
|
|
||||||
|
|
||||||
use App\Repository\ProductsRepository;
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
|
||||||
use Doctrine\Common\Collections\Collection;
|
|
||||||
use Doctrine\DBAL\Types\Types;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: ProductsRepository::class)]
|
|
||||||
class Products
|
|
||||||
{
|
|
||||||
#[ORM\Id]
|
|
||||||
#[ORM\GeneratedValue]
|
|
||||||
#[ORM\Column]
|
|
||||||
private ?int $id = null;
|
|
||||||
|
|
||||||
#[ORM\Column(type: Types::GUID, nullable: true)]
|
|
||||||
private ?string $shopware_id = null;
|
|
||||||
|
|
||||||
#[ORM\OneToMany(mappedBy: 'prod_id', targetEntity: Stock::class)]
|
|
||||||
private Collection $stocks;
|
|
||||||
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->stocks = new ArrayCollection();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getId(): ?int
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getShopwareId(): ?string
|
|
||||||
{
|
|
||||||
return $this->shopware_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setShopwareId(?string $shopware_id): self
|
|
||||||
{
|
|
||||||
$this->shopware_id = $shopware_id;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Collection<int, Stock>
|
|
||||||
*/
|
|
||||||
public function getStocks(): Collection
|
|
||||||
{
|
|
||||||
return $this->stocks;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addStock(Stock $stock): self
|
|
||||||
{
|
|
||||||
if (!$this->stocks->contains($stock)) {
|
|
||||||
$this->stocks->add($stock);
|
|
||||||
$stock->setProdId($this);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeStock(Stock $stock): self
|
|
||||||
{
|
|
||||||
if ($this->stocks->removeElement($stock)) {
|
|
||||||
// set the owning side to null (unless already changed)
|
|
||||||
if ($stock->getProdId() === $this) {
|
|
||||||
$stock->setProdId(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
|
50
src/Entity/Settings.php
Normal file
50
src/Entity/Settings.php
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity;
|
||||||
|
|
||||||
|
use App\Repository\SettingsRepository;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
#[ORM\Entity(repositoryClass: SettingsRepository::class)]
|
||||||
|
class Settings
|
||||||
|
{
|
||||||
|
#[ORM\Id]
|
||||||
|
#[ORM\GeneratedValue]
|
||||||
|
#[ORM\Column]
|
||||||
|
private ?int $id = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private ?string $name = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private ?string $value = null;
|
||||||
|
|
||||||
|
public function getId(): ?int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(): ?string
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setName(string $name): self
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getValue(): ?string
|
||||||
|
{
|
||||||
|
return $this->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setValue(string $value): self
|
||||||
|
{
|
||||||
|
$this->value = $value;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
@ -10,92 +10,66 @@ class Stock
|
|||||||
{
|
{
|
||||||
#[ORM\Id]
|
#[ORM\Id]
|
||||||
#[ORM\GeneratedValue]
|
#[ORM\GeneratedValue]
|
||||||
#[ORM\Column(type: 'integer')]
|
#[ORM\Column]
|
||||||
private $id;
|
private ?int $id = null;
|
||||||
|
|
||||||
#[ORM\Column(type: 'string', length: 255)]
|
#[ORM\Column]
|
||||||
private $gtin;
|
private ?int $instock = null;
|
||||||
|
|
||||||
#[ORM\Column(type: 'integer')]
|
#[ORM\OneToOne(mappedBy: 'stock', cascade: ['persist', 'remove'])]
|
||||||
private $stock;
|
private ?Product $product = null;
|
||||||
|
|
||||||
#[ORM\Column(type: 'datetime', nullable: true)]
|
|
||||||
private $update_time;
|
|
||||||
|
|
||||||
#[ORM\ManyToOne(targetEntity: Warehouse::class, inversedBy: 'warehouse_id')]
|
|
||||||
private $warehouse_id;
|
|
||||||
|
|
||||||
#[ORM\ManyToOne(inversedBy: 'stocks')]
|
#[ORM\ManyToOne(inversedBy: 'stocks')]
|
||||||
private ?Products $prod_id = null;
|
private ?Warehouse $warehouse = null;
|
||||||
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
{
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getGtin(): ?string
|
public function getInstock(): ?int
|
||||||
{
|
{
|
||||||
return $this->gtin;
|
return $this->instock;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setGtin(string $gtin): self
|
public function setInstock(int $instock): self
|
||||||
{
|
{
|
||||||
$this->gtin = $gtin;
|
$this->instock = $instock;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStock(): ?int
|
public function getProduct(): ?Product
|
||||||
{
|
{
|
||||||
return $this->stock;
|
return $this->product;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setStock(int $stock): self
|
public function setProduct(?Product $product): self
|
||||||
{
|
{
|
||||||
$this->stock = $stock;
|
// unset the owning side of the relation if necessary
|
||||||
|
if ($product === null && $this->product !== null) {
|
||||||
|
$this->product->setStock(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set the owning side of the relation if necessary
|
||||||
|
if ($product !== null && $product->getStock() !== $this) {
|
||||||
|
$product->setStock($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->product = $product;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUpdateTime(): ?\DateTimeInterface
|
public function getWarehouse(): ?Warehouse
|
||||||
{
|
{
|
||||||
return $this->update_time;
|
return $this->warehouse;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setUpdateTime(?\DateTimeInterface $update_time): self
|
public function setWarehouse(?Warehouse $warehouse): self
|
||||||
{
|
{
|
||||||
$this->update_time = $update_time;
|
$this->warehouse = $warehouse;
|
||||||
|
|
||||||
return $this;
|
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 getProdId(): ?Products
|
|
||||||
{
|
|
||||||
return $this->prod_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setProdId(?Products $prod_id): self
|
|
||||||
{
|
|
||||||
$this->prod_id = $prod_id;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setWarehouse(Warehouse $warehouse): self
|
|
||||||
{
|
|
||||||
$this->warehouse_id = $warehouse->getId();
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -12,18 +12,21 @@ class Warehouse
|
|||||||
{
|
{
|
||||||
#[ORM\Id]
|
#[ORM\Id]
|
||||||
#[ORM\GeneratedValue]
|
#[ORM\GeneratedValue]
|
||||||
#[ORM\Column(type: 'integer')]
|
#[ORM\Column]
|
||||||
private $id;
|
private ?int $id = null;
|
||||||
|
|
||||||
#[ORM\OneToMany(mappedBy: 'warehouse_id', targetEntity: Stock::class)]
|
#[ORM\Column(length: 255)]
|
||||||
private $warehouse_id;
|
private ?string $name = null;
|
||||||
|
|
||||||
#[ORM\Column(type: 'integer')]
|
#[ORM\Column]
|
||||||
private $priority;
|
private ?int $prio = null;
|
||||||
|
|
||||||
|
#[ORM\OneToMany(mappedBy: 'warehouse', targetEntity: Stock::class)]
|
||||||
|
private Collection $stocks;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->warehouse_id = new ArrayCollection();
|
$this->stocks = new ArrayCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
@ -31,16 +34,26 @@ class Warehouse
|
|||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setID(int $id): self
|
public function getName(): ?string
|
||||||
{
|
{
|
||||||
$this->id = $id;
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setName(string $name): self
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setWarehouseId(int $warehouse_id): self
|
public function getPrio(): ?int
|
||||||
{
|
{
|
||||||
$this->warehouse_id = $warehouse_id;
|
return $this->prio;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPrio(int $prio): self
|
||||||
|
{
|
||||||
|
$this->prio = $prio;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -48,41 +61,30 @@ class Warehouse
|
|||||||
/**
|
/**
|
||||||
* @return Collection<int, Stock>
|
* @return Collection<int, Stock>
|
||||||
*/
|
*/
|
||||||
public function getWarehouseId(): Collection
|
public function getStocks(): Collection
|
||||||
{
|
{
|
||||||
return $this->warehouse_id;
|
return $this->stocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addWarehouseId(Stock $warehouseId): self
|
public function addStock(Stock $stock): self
|
||||||
{
|
{
|
||||||
if (!$this->warehouse_id->contains($warehouseId)) {
|
if (!$this->stocks->contains($stock)) {
|
||||||
$this->warehouse_id[] = $warehouseId;
|
$this->stocks->add($stock);
|
||||||
$warehouseId->setWarehouseId($this);
|
$stock->setWarehouse($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function removeWarehouseId(Stock $warehouseId): self
|
public function removeStock(Stock $stock): self
|
||||||
{
|
{
|
||||||
if ($this->warehouse_id->removeElement($warehouseId)) {
|
if ($this->stocks->removeElement($stock)) {
|
||||||
// set the owning side to null (unless already changed)
|
// set the owning side to null (unless already changed)
|
||||||
if ($warehouseId->getWarehouseId() === $this) {
|
if ($stock->getWarehouse() === $this) {
|
||||||
$warehouseId->setWarehouseId(null);
|
$stock->setWarehouse(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPriority(): ?int
|
|
||||||
{
|
|
||||||
return $this->priority;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setPriority(int $priority): self
|
|
||||||
{
|
|
||||||
$this->priority = $priority;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,48 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
|
|
||||||
namespace App\EventSubscriber;
|
|
||||||
|
|
||||||
use ApiPlatform\Core\EventListener\EventPriorities;
|
|
||||||
use App\Command\SwGetOrdersCommand;
|
|
||||||
use App\Entity\Orders;
|
|
||||||
use Psr\Log\LoggerInterface;
|
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Symfony\Component\HttpKernel\Event\ViewEvent;
|
|
||||||
use Symfony\Component\HttpKernel\KernelEvents;
|
|
||||||
|
|
||||||
final class OrdersSubscriber implements EventSubscriberInterface
|
|
||||||
{
|
|
||||||
private LoggerInterface $logger;
|
|
||||||
|
|
||||||
public function __construct(LoggerInterface $logger)
|
|
||||||
{
|
|
||||||
$this->logger = $logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array[]
|
|
||||||
*/
|
|
||||||
public static function getSubscribedEvents()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
KernelEvents::VIEW => ['getShopwareOrder', EventPriorities::POST_WRITE],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ViewEvent $event
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function getShopwareOrder(ViewEvent $event): void
|
|
||||||
{
|
|
||||||
$data = $event->getControllerResult();
|
|
||||||
$method = $event->getRequest()->getMethod();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$this->logger->info('hier');
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Form;
|
|
||||||
|
|
||||||
use App\Entity\Orders;
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
|
||||||
|
|
||||||
class OrdersType extends AbstractType
|
|
||||||
{
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
|
||||||
{
|
|
||||||
$builder
|
|
||||||
->add('order_id')
|
|
||||||
->add('status')
|
|
||||||
->add('data')
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function configureOptions(OptionsResolver $resolver): void
|
|
||||||
{
|
|
||||||
$resolver->setDefaults([
|
|
||||||
'data_class' => Orders::class,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,8 +3,10 @@
|
|||||||
namespace App\Helper;
|
namespace App\Helper;
|
||||||
|
|
||||||
|
|
||||||
|
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\StockRepository;
|
use App\Repository\StockRepository;
|
||||||
use App\Repository\WarehouseRepository;
|
use App\Repository\WarehouseRepository;
|
||||||
use Doctrine\ORM\EntityManager;
|
use Doctrine\ORM\EntityManager;
|
||||||
@ -13,17 +15,19 @@ use Symfony\Component\Finder\Finder;
|
|||||||
|
|
||||||
class HiltesImport
|
class HiltesImport
|
||||||
{
|
{
|
||||||
|
private $productRepository;
|
||||||
private $stockRepository;
|
private $stockRepository;
|
||||||
private $warehouseRepository;
|
private $warehouseRepository;
|
||||||
private $logger;
|
private $logger;
|
||||||
protected $currentDirPath;
|
protected $currentDirPath;
|
||||||
protected $arrData = array();
|
protected $arrData = array();
|
||||||
|
|
||||||
public function __construct(StockRepository $stockRepository, WarehouseRepository $warehouseRepository, LoggerInterface $logger)
|
public function __construct(ProductRepository $productRepository, LoggerInterface $logger)
|
||||||
{
|
{
|
||||||
$this->stockRepository = $stockRepository;
|
// $this->stockRepository = $stockRepository;
|
||||||
$this->warehouseRepository = $warehouseRepository;
|
// $this->warehouseRepository = $warehouseRepository;
|
||||||
|
|
||||||
|
$this->productRepository = $productRepository;
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
|
|
||||||
$this->currentDirPath = getcwd();
|
$this->currentDirPath = getcwd();
|
||||||
@ -50,7 +54,6 @@ class HiltesImport
|
|||||||
}
|
}
|
||||||
protected function getFiles()
|
protected function getFiles()
|
||||||
{
|
{
|
||||||
$return = true;
|
|
||||||
$finder = Finder::create();
|
$finder = Finder::create();
|
||||||
$finder
|
$finder
|
||||||
->in($this->currentDirPath.'/hiltes/h2c/')
|
->in($this->currentDirPath.'/hiltes/h2c/')
|
||||||
@ -65,47 +68,34 @@ class HiltesImport
|
|||||||
'fileSize' => $file->getFileInfo()->getSize(),
|
'fileSize' => $file->getFileInfo()->getSize(),
|
||||||
'onlyFileName' => $file->getRelativePathname(),
|
'onlyFileName' => $file->getRelativePathname(),
|
||||||
);
|
);
|
||||||
/*
|
|
||||||
$absoluteFilePath = $file->getRealPath();
|
|
||||||
$fileInfo = $file->getFileInfo();
|
|
||||||
$fileNameWithExtension = $file->getRelativePathname();
|
|
||||||
dump($absoluteFilePath);
|
|
||||||
dump($fileInfo->getSize());
|
|
||||||
dump($fileNameWithExtension);
|
|
||||||
*/
|
|
||||||
#dump($this->arrData);
|
|
||||||
}
|
}
|
||||||
return $return;
|
|
||||||
}else{
|
}else{
|
||||||
return $return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
#print_r(\iterator_to_array($finder,true));
|
|
||||||
}
|
}
|
||||||
protected function loadFiles($srcFile,$size)
|
protected function loadFiles($srcFile,$size)
|
||||||
{
|
{
|
||||||
# $t = memory_get_usage();
|
|
||||||
# dump($t);
|
|
||||||
$file = new \SplFileObject($srcFile);
|
$file = new \SplFileObject($srcFile);
|
||||||
# dump(memory_get_usage()-$t);
|
|
||||||
|
|
||||||
dump($file->getRealPath());
|
dump($file->getRealPath());
|
||||||
|
|
||||||
$this->logger->info('Starte Import von ' . $file->getRealPath());
|
$this->logger->info('Starte Import von ' . $file->getRealPath());
|
||||||
|
|
||||||
$c = 0;
|
$c = 0;
|
||||||
while (!$file->eof()) {
|
while (!$file->eof()) {
|
||||||
$c++;
|
|
||||||
// Header überspringen
|
// Header überspringen
|
||||||
if($c == 1){ continue; }
|
$c++;
|
||||||
|
|
||||||
#*** Convertiert die Zeile in UTF8
|
#*** Convertiert die Zeile in UTF8
|
||||||
//$str = iconv('ISO-8859-1','UTF-8',$file->fgets());
|
//$str = iconv('ISO-8859-1','UTF-8',$file->fgets());
|
||||||
|
|
||||||
#*** Zerlegt die Zeile **********
|
#*** Zerlegt die Zeile **********
|
||||||
$arr = $this->splitLine($file->fgets());
|
$data = $file->fgets();
|
||||||
$this->switchSaveData($arr);
|
if($c <= 1){ continue; }
|
||||||
|
|
||||||
|
$this->switchSaveData($this->splitLine($data));
|
||||||
}
|
}
|
||||||
|
|
||||||
dump($c . ' Datensätze importiert');
|
dump($c . ' Datensätze importiert');
|
||||||
@ -180,9 +170,7 @@ class HiltesImport
|
|||||||
$arr[$k] = trim($v);
|
$arr[$k] = trim($v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected function saveInfoDatei(Array $arr){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $arr
|
* @param array $arr
|
||||||
@ -190,41 +178,57 @@ class HiltesImport
|
|||||||
*/
|
*/
|
||||||
protected function saveData(Array $arr){
|
protected function saveData(Array $arr){
|
||||||
#dump($arr);
|
#dump($arr);
|
||||||
$stock = new Stock();
|
$prod = new Product();
|
||||||
|
|
||||||
|
$stock = new Stock();
|
||||||
|
$stock->setInstock((int)$arr[2]);
|
||||||
|
|
||||||
|
$warehouse = new Warehouse();
|
||||||
|
$warehouse->setName($arr[0]);
|
||||||
|
// $stock->setWarehouse($warehouse);
|
||||||
|
|
||||||
#menge;
|
#menge;
|
||||||
$stock->setStock((int)$arr[2]);
|
$prod->setStock($stock);
|
||||||
|
|
||||||
|
#gtin;
|
||||||
|
$prod->setGtin($arr[1]);
|
||||||
|
|
||||||
|
$prod->setShopwareId("");
|
||||||
|
|
||||||
|
|
||||||
|
// dump($prod);
|
||||||
|
|
||||||
|
$this->productRepository->save($prod,true);
|
||||||
|
|
||||||
|
//$stock->setStock((int)$arr[2]);
|
||||||
|
|
||||||
#filiale;
|
#filiale;
|
||||||
|
//
|
||||||
$warehouse = $this->warehouseRepository->findOneBy(['id'=> $arr[2]]);
|
// $warehouse = $this->warehouseRepository->findOneBy(['id'=> $arr[2]]);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
if($warehouse instanceof Warehouse){
|
// if($warehouse instanceof Warehouse){
|
||||||
$stock->setWarehouseId($warehouse->getId());
|
// $stock->setWarehouseId($warehouse->getId());
|
||||||
}else{
|
// }else{
|
||||||
$warehouse = new Warehouse();
|
// $warehouse = new Warehouse();
|
||||||
$warehouse->setId((int)$arr[2]);
|
// $warehouse->setId((int)$arr[2]);
|
||||||
$warehouse->setPriority(0);
|
// $warehouse->setPriority(0);
|
||||||
$id = $this->warehouseRepository->add($warehouse, true);
|
// $id = $this->warehouseRepository->add($warehouse, true);
|
||||||
# $stock->setWarehouseId($id);
|
// # $stock->setWarehouseId($id);
|
||||||
}
|
// }
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
||||||
// $stock->setWarehouseId($warehouse->getId());
|
// $stock->setWarehouseId($warehouse->getId());
|
||||||
|
|
||||||
#gtin;
|
|
||||||
$stock->setGtin($arr[1]);
|
|
||||||
|
|
||||||
try{
|
// try{
|
||||||
$this->stockRepository->upsert($stock);
|
// $this->stockRepository->upsert($stock);
|
||||||
}catch (\Exception $e){
|
// }catch (\Exception $e){
|
||||||
$this->logger->error($e->getMessage());
|
// $this->logger->error($e->getMessage());
|
||||||
dump($e->getMessage());
|
// dump($e->getMessage());
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,6 +73,13 @@ class Shopware
|
|||||||
public function setProduct(Products $product){
|
public function setProduct(Products $product){
|
||||||
$context = new Context($_ENV['SHOPWARE_API_URL'], $this->shopwareAuth());
|
$context = new Context($_ENV['SHOPWARE_API_URL'], $this->shopwareAuth());
|
||||||
|
|
||||||
|
//prüfen ob Shopware Produktid schon bekannt ist
|
||||||
|
if($product->getProductId() == null){
|
||||||
|
$this->logger->error('Shopware Produkt ID ist nicht bekannt');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$productRepository = RepositoryFactory::create(ProductDefinition::ENTITY_NAME);
|
$productRepository = RepositoryFactory::create(ProductDefinition::ENTITY_NAME);
|
||||||
$productRepository->update($product, $context);
|
$productRepository->update($product, $context);
|
||||||
}
|
}
|
||||||
|
66
src/Repository/OrderRepository.php
Normal file
66
src/Repository/OrderRepository.php
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repository;
|
||||||
|
|
||||||
|
use App\Entity\Order;
|
||||||
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends ServiceEntityRepository<Order>
|
||||||
|
*
|
||||||
|
* @method Order|null find($id, $lockMode = null, $lockVersion = null)
|
||||||
|
* @method Order|null findOneBy(array $criteria, array $orderBy = null)
|
||||||
|
* @method Order[] findAll()
|
||||||
|
* @method Order[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||||
|
*/
|
||||||
|
class OrderRepository extends ServiceEntityRepository
|
||||||
|
{
|
||||||
|
public function __construct(ManagerRegistry $registry)
|
||||||
|
{
|
||||||
|
parent::__construct($registry, Order::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function save(Order $entity, bool $flush = false): void
|
||||||
|
{
|
||||||
|
$this->getEntityManager()->persist($entity);
|
||||||
|
|
||||||
|
if ($flush) {
|
||||||
|
$this->getEntityManager()->flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function remove(Order $entity, bool $flush = false): void
|
||||||
|
{
|
||||||
|
$this->getEntityManager()->remove($entity);
|
||||||
|
|
||||||
|
if ($flush) {
|
||||||
|
$this->getEntityManager()->flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * @return Order[] Returns an array of Order objects
|
||||||
|
// */
|
||||||
|
// public function findByExampleField($value): array
|
||||||
|
// {
|
||||||
|
// return $this->createQueryBuilder('o')
|
||||||
|
// ->andWhere('o.exampleField = :val')
|
||||||
|
// ->setParameter('val', $value)
|
||||||
|
// ->orderBy('o.id', 'ASC')
|
||||||
|
// ->setMaxResults(10)
|
||||||
|
// ->getQuery()
|
||||||
|
// ->getResult()
|
||||||
|
// ;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public function findOneBySomeField($value): ?Order
|
||||||
|
// {
|
||||||
|
// return $this->createQueryBuilder('o')
|
||||||
|
// ->andWhere('o.exampleField = :val')
|
||||||
|
// ->setParameter('val', $value)
|
||||||
|
// ->getQuery()
|
||||||
|
// ->getOneOrNullResult()
|
||||||
|
// ;
|
||||||
|
// }
|
||||||
|
}
|
69
src/Repository/ProductRepository.php
Normal file
69
src/Repository/ProductRepository.php
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repository;
|
||||||
|
|
||||||
|
use App\Entity\Product;
|
||||||
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends ServiceEntityRepository<Product>
|
||||||
|
*
|
||||||
|
* @method Product|null find($id, $lockMode = null, $lockVersion = null)
|
||||||
|
* @method Product|null findOneBy(array $criteria, array $orderBy = null)
|
||||||
|
* @method Product[] findAll()
|
||||||
|
* @method Product[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||||
|
*/
|
||||||
|
class ProductRepository extends ServiceEntityRepository
|
||||||
|
{
|
||||||
|
public function __construct(ManagerRegistry $registry)
|
||||||
|
{
|
||||||
|
parent::__construct($registry, Product::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function save(Product $entity, bool $flush = false): void
|
||||||
|
{
|
||||||
|
|
||||||
|
$entity->setUpdateTime(new \DateTime());
|
||||||
|
|
||||||
|
$this->getEntityManager()->persist($entity);
|
||||||
|
|
||||||
|
if ($flush) {
|
||||||
|
$this->getEntityManager()->flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function remove(Product $entity, bool $flush = false): void
|
||||||
|
{
|
||||||
|
$this->getEntityManager()->remove($entity);
|
||||||
|
|
||||||
|
if ($flush) {
|
||||||
|
$this->getEntityManager()->flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * @return Product[] Returns an array of Product objects
|
||||||
|
// */
|
||||||
|
// public function findByExampleField($value): array
|
||||||
|
// {
|
||||||
|
// return $this->createQueryBuilder('p')
|
||||||
|
// ->andWhere('p.exampleField = :val')
|
||||||
|
// ->setParameter('val', $value)
|
||||||
|
// ->orderBy('p.id', 'ASC')
|
||||||
|
// ->setMaxResults(10)
|
||||||
|
// ->getQuery()
|
||||||
|
// ->getResult()
|
||||||
|
// ;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public function findOneBySomeField($value): ?Product
|
||||||
|
// {
|
||||||
|
// return $this->createQueryBuilder('p')
|
||||||
|
// ->andWhere('p.exampleField = :val')
|
||||||
|
// ->setParameter('val', $value)
|
||||||
|
// ->getQuery()
|
||||||
|
// ->getOneOrNullResult()
|
||||||
|
// ;
|
||||||
|
// }
|
||||||
|
}
|
66
src/Repository/SettingsRepository.php
Normal file
66
src/Repository/SettingsRepository.php
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repository;
|
||||||
|
|
||||||
|
use App\Entity\Settings;
|
||||||
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends ServiceEntityRepository<Settings>
|
||||||
|
*
|
||||||
|
* @method Settings|null find($id, $lockMode = null, $lockVersion = null)
|
||||||
|
* @method Settings|null findOneBy(array $criteria, array $orderBy = null)
|
||||||
|
* @method Settings[] findAll()
|
||||||
|
* @method Settings[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||||
|
*/
|
||||||
|
class SettingsRepository extends ServiceEntityRepository
|
||||||
|
{
|
||||||
|
public function __construct(ManagerRegistry $registry)
|
||||||
|
{
|
||||||
|
parent::__construct($registry, Settings::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function save(Settings $entity, bool $flush = false): void
|
||||||
|
{
|
||||||
|
$this->getEntityManager()->persist($entity);
|
||||||
|
|
||||||
|
if ($flush) {
|
||||||
|
$this->getEntityManager()->flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function remove(Settings $entity, bool $flush = false): void
|
||||||
|
{
|
||||||
|
$this->getEntityManager()->remove($entity);
|
||||||
|
|
||||||
|
if ($flush) {
|
||||||
|
$this->getEntityManager()->flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * @return Settings[] Returns an array of Settings objects
|
||||||
|
// */
|
||||||
|
// public function findByExampleField($value): array
|
||||||
|
// {
|
||||||
|
// return $this->createQueryBuilder('s')
|
||||||
|
// ->andWhere('s.exampleField = :val')
|
||||||
|
// ->setParameter('val', $value)
|
||||||
|
// ->orderBy('s.id', 'ASC')
|
||||||
|
// ->setMaxResults(10)
|
||||||
|
// ->getQuery()
|
||||||
|
// ->getResult()
|
||||||
|
// ;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public function findOneBySomeField($value): ?Settings
|
||||||
|
// {
|
||||||
|
// return $this->createQueryBuilder('s')
|
||||||
|
// ->andWhere('s.exampleField = :val')
|
||||||
|
// ->setParameter('val', $value)
|
||||||
|
// ->getQuery()
|
||||||
|
// ->getOneOrNullResult()
|
||||||
|
// ;
|
||||||
|
// }
|
||||||
|
}
|
@ -3,7 +3,6 @@
|
|||||||
namespace App\Repository;
|
namespace App\Repository;
|
||||||
|
|
||||||
use App\Entity\Stock;
|
use App\Entity\Stock;
|
||||||
use App\Entity\Warehouse;
|
|
||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
@ -22,7 +21,7 @@ class StockRepository extends ServiceEntityRepository
|
|||||||
parent::__construct($registry, Stock::class);
|
parent::__construct($registry, Stock::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function add(Stock $entity, bool $flush = false): void
|
public function save(Stock $entity, bool $flush = false): void
|
||||||
{
|
{
|
||||||
$this->getEntityManager()->persist($entity);
|
$this->getEntityManager()->persist($entity);
|
||||||
|
|
||||||
@ -31,57 +30,6 @@ class StockRepository extends ServiceEntityRepository
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Stock $entity
|
|
||||||
* @param int $id
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function update(Stock $entity, string $id): void
|
|
||||||
{
|
|
||||||
|
|
||||||
$stock = $this->getEntityManager()->getRepository(Stock::class)->find($id);
|
|
||||||
|
|
||||||
if (!$stock) {
|
|
||||||
throw $this->createNotFoundException(
|
|
||||||
'No product found for id '.$id
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$stock->setStock($entity->getStock());
|
|
||||||
$stock->setUpdateTime(new \DateTime('now'));
|
|
||||||
|
|
||||||
$this->getEntityManager()->flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Stock $entity
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function upsert(Stock $stock): void
|
|
||||||
{
|
|
||||||
//$stock = $this->findByGtin($entity->getGtin());
|
|
||||||
|
|
||||||
// $warehouse = $this->getEntityManager()->find(Warehouse::class, $stock->getWarehouseId());
|
|
||||||
// $stock->setWarehouse($warehouse);
|
|
||||||
//
|
|
||||||
// $this->getEntityManager()->persist($stock);
|
|
||||||
//
|
|
||||||
// $this->getEntityManager()->flush();
|
|
||||||
|
|
||||||
$s = $this->findOneBy([
|
|
||||||
'gtin' => $stock->getGtin(),
|
|
||||||
//'warehouse_id' => $stock->getWarehouseId()
|
|
||||||
]);
|
|
||||||
|
|
||||||
if ($s) {
|
|
||||||
// $stock->setStock($entity->getStock());
|
|
||||||
// $this->getEntityManager()->flush();
|
|
||||||
$this->update($stock,$s->getId());
|
|
||||||
}else{
|
|
||||||
$this->add($stock,true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function remove(Stock $entity, bool $flush = false): void
|
public function remove(Stock $entity, bool $flush = false): void
|
||||||
{
|
{
|
||||||
$this->getEntityManager()->remove($entity);
|
$this->getEntityManager()->remove($entity);
|
||||||
@ -91,23 +39,20 @@ class StockRepository extends ServiceEntityRepository
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* @return Stock[] Returns an array of Stock objects
|
// * @return Stock[] Returns an array of Stock objects
|
||||||
*/
|
// */
|
||||||
public function findByGtin($value): array
|
// public function findByExampleField($value): array
|
||||||
{
|
// {
|
||||||
return $this->createQueryBuilder('s')
|
// return $this->createQueryBuilder('s')
|
||||||
->andWhere('s.gtin = :val')
|
// ->andWhere('s.exampleField = :val')
|
||||||
->setParameter('val', $value)
|
// ->setParameter('val', $value)
|
||||||
->orderBy('s.id', 'ASC')
|
// ->orderBy('s.id', 'ASC')
|
||||||
->setMaxResults(1)
|
// ->setMaxResults(10)
|
||||||
->getQuery()
|
// ->getQuery()
|
||||||
->getResult()
|
// ->getResult()
|
||||||
;
|
// ;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// public function findOneBySomeField($value): ?Stock
|
// public function findOneBySomeField($value): ?Stock
|
||||||
// {
|
// {
|
||||||
|
@ -21,15 +21,13 @@ class WarehouseRepository extends ServiceEntityRepository
|
|||||||
parent::__construct($registry, Warehouse::class);
|
parent::__construct($registry, Warehouse::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function add(Warehouse $entity, bool $flush = false): ?int
|
public function save(Warehouse $entity, bool $flush = false): void
|
||||||
{
|
{
|
||||||
$this->getEntityManager()->persist($entity);
|
$this->getEntityManager()->persist($entity);
|
||||||
|
|
||||||
if ($flush) {
|
if ($flush) {
|
||||||
$this->getEntityManager()->flush();
|
$this->getEntityManager()->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $entity->getId();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function remove(Warehouse $entity, bool $flush = false): void
|
public function remove(Warehouse $entity, bool $flush = false): void
|
||||||
|
@ -164,12 +164,12 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"symfony/phpunit-bridge": {
|
"symfony/phpunit-bridge": {
|
||||||
"version": "6.1",
|
"version": "6.2",
|
||||||
"recipe": {
|
"recipe": {
|
||||||
"repo": "github.com/symfony/recipes",
|
"repo": "github.com/symfony/recipes",
|
||||||
"branch": "main",
|
"branch": "main",
|
||||||
"version": "5.3",
|
"version": "5.3",
|
||||||
"ref": "97cb3dc7b0f39c7cfc4b7553504c9d7b7795de96"
|
"ref": "819d3d2ffa4590eba0b8f4f3e5e89415ee4e45c3"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
".env.test",
|
".env.test",
|
||||||
|
@ -9,3 +9,7 @@ if (file_exists(dirname(__DIR__).'/config/bootstrap.php')) {
|
|||||||
} elseif (method_exists(Dotenv::class, 'bootEnv')) {
|
} elseif (method_exists(Dotenv::class, 'bootEnv')) {
|
||||||
(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
|
(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($_SERVER['APP_DEBUG']) {
|
||||||
|
umask(0000);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user