<?php
declare(strict_types=1);
namespace App\Entity\Product;
use App\Entity\PriceHistory\ChannelPricingHistory;
use App\Entity\PriceHistory\TierPriceHistory;
use Brille24\SyliusTierPricePlugin\Entity\ProductVariantInterface;
use Brille24\SyliusTierPricePlugin\Traits\TierPriceableTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Sylius\Component\Core\Model\ProductVariant as BaseProductVariant;
use Sylius\Component\Product\Model\ProductVariantTranslationInterface;
/**
* @ORM\Entity
* @ORM\Table(name="sylius_product_variant")
*/
class ProductVariant extends BaseProductVariant implements ProductVariantInterface
{
use TierPriceableTrait;
public function __construct()
{
parent::__construct();
$this->initTierPriceableTrait();
// $this->channelPricingsHistory = new ArrayCollection();
// $this->tierPricesHistory = new ArrayCollection();
}
protected function createTranslation(): ProductVariantTranslationInterface
{
return new ProductVariantTranslation();
}
public function getDescription(): ?string
{
return $this->getTranslation()->getDescription();
}
/** @ORM\Column(type="string", length=511, nullable=true) */
protected ?string $storageArea = null;
/** @ORM\Column(type="string", length=511, nullable=true) */
protected ?string $eanCode = null;
/** @ORM\Column(name="purchase_price", type="integer", nullable=true) */
protected ?int $purchasePrice;
/**
* @var \DateTimeInterface|null
*
* @ORM\Column(name="restocking_date", type="datetime", nullable=true)
*/
protected $restockingDate;
/**
* @var \DateTimeInterface|null
*
* @ORM\Column(name="archived_at", type="datetime", nullable=true)
*/
protected $archivedAt;
/**
* @ORM\OneToMany(
* targetEntity="Brille24\SyliusTierPricePlugin\Entity\TierPriceInterface",
* mappedBy="productVariant",
* cascade={"all"},
* orphanRemoval=true
* )
* @ORM\OrderBy({"customerGroup" = "ASC", "qty" = "ASC"})
*/
protected $tierPrices;
/** @ORM\Column(name="unlimited_stock", type="boolean", nullable=false, options={"default" : 0}) */
protected bool $unlimitedStock = false;
// /**
// * @ORM\OneToMany(
// * targetEntity="App\Entity\PriceHistory\ChannelPricingHistory",
// * mappedBy="owner",
// * cascade={"all"},
// * orphanRemoval=true
// * )
// * @ORM\OrderBy({"customerGroup" = "ASC", "qty" = "ASC"})
// */
// protected Collection $channelPricingsHistory;
/**
// * @ORM\OneToMany(
// * targetEntity="App\Entity\PriceHistory\TierPriceHistory",
// * mappedBy="owner",
// * cascade={"all"},
// * orphanRemoval=true
// * )
// * @ORM\OrderBy({"customerGroup" = "ASC", "qty" = "ASC"})
// */
// protected Collection $tierPricesHistory;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Product\ProductVariant", cascade={"persist"})
* @ORM\JoinColumn(name="alternative_variant_id", referencedColumnName="id", onDelete="SET NULL", nullable=true)
*/
protected ?\Sylius\Component\Core\Model\ProductVariantInterface $alternativeVariant = null;
/** @ORM\Column(type="string", length=511, nullable=true) */
protected ?string $articleCaractValPhotoId = null;
public function getStorageArea(): ?string
{
return $this->storageArea;
}
public function setStorageArea(?string $storageArea): void
{
$this->storageArea = $storageArea;
}
public function getEanCode(): ?string
{
return $this->eanCode;
}
public function setEanCode(?string $eanCode): void
{
$this->eanCode = $eanCode;
}
public function getPurchasePrice(): ?int
{
return $this->purchasePrice;
}
public function setPurchasePrice(?int $purchasePrice): void
{
$this->purchasePrice = $purchasePrice;
}
public function getArchivedAt(): ?\DateTimeInterface
{
return $this->archivedAt;
}
public function setArchivedAt(?\DateTimeInterface $archivedAt): void
{
$this->archivedAt = $archivedAt;
}
/**
* Get the value of restockingDate.
*/
public function getRestockingDate(): ?\DateTimeInterface
{
return $this->restockingDate;
}
/**
* Set the value of restockingDate.
*
* @return self
*/
public function setRestockingDate(?\DateTimeInterface $restockingDate)
{
$this->restockingDate = $restockingDate;
return $this;
}
// public function getChannelPricingsHistory(): Collection
// {
// return $this->channelPricingsHistory;
// }
//
// public function addChannelPricingHistory(ChannelPricingHistory $channelPricingHistory): self
// {
// if (!$this->channelPricingsHistory->contains($channelPricingHistory)) {
// $this->channelPricingsHistory[] = $channelPricingHistory;
// $channelPricingHistory->setOwner($this);
// }
//
// return $this;
// }
//
// public function removeChannelPricingHistory(ChannelPricingHistory $channelPricingHistory): self
// {
// if ($this->channelPricingsHistory->removeElement($channelPricingHistory)) {
// // set the owning side to null (unless already changed)
// if ($channelPricingHistory->getOwner() === $this) {
// $channelPricingHistory->setOwner(null);
// }
// }
//
// return $this;
// }
// public function getTierPricesHistory(): Collection
// {
// return $this->tierPricesHistory;
// }
//
// public function addTierPriceHistory(TierPriceHistory $tierPrice): self
// {
// if (!$this->tierPricesHistory->contains($tierPrice)) {
// $this->tierPricesHistory[] = $tierPrice;
// $tierPrice->setOwner($this);
// }
//
// return $this;
// }
//
// public function removeTierPriceHistory(TierPriceHistory $tierPrice): self
// {
// if ($this->channelPricingsHistory->removeElement($tierPrice)) {
// // set the owning side to null (unless already changed)
// if ($tierPrice->getOwner() === $this) {
// $tierPrice->setOwner(null);
// }
// }
//
// return $this;
// }
public function getAlternativeVariant(): ?\Sylius\Component\Core\Model\ProductVariantInterface
{
return $this->alternativeVariant;
}
public function setAlternativeVariant(?\Sylius\Component\Core\Model\ProductVariantInterface $alternativeVariant): void
{
$this->alternativeVariant = $alternativeVariant;
}
public function isUnlimitedStock(): bool
{
return $this->unlimitedStock;
}
public function setUnlimitedStock(bool $unlimitedStock): void
{
$this->unlimitedStock = $unlimitedStock;
}
public function getArticleCaractValPhotoId(): ?string
{
return $this->articleCaractValPhotoId;
}
public function setArticleCaractValPhotoId(?string $articleCaractValPhotoId): void
{
$this->articleCaractValPhotoId = $articleCaractValPhotoId;
}
}