src/Entity/Product/ProductVariant.php line 21

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Product;
  4. use App\Entity\PriceHistory\ChannelPricingHistory;
  5. use App\Entity\PriceHistory\TierPriceHistory;
  6. use Brille24\SyliusTierPricePlugin\Entity\ProductVariantInterface;
  7. use Brille24\SyliusTierPricePlugin\Traits\TierPriceableTrait;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Sylius\Component\Core\Model\ProductVariant as BaseProductVariant;
  12. use Sylius\Component\Product\Model\ProductVariantTranslationInterface;
  13. /**
  14.  * @ORM\Entity
  15.  * @ORM\Table(name="sylius_product_variant")
  16.  */
  17. class ProductVariant extends BaseProductVariant implements ProductVariantInterface
  18. {
  19.     use TierPriceableTrait;
  20.     public function __construct()
  21.     {
  22.         parent::__construct();
  23.         $this->initTierPriceableTrait();
  24. //        $this->channelPricingsHistory = new ArrayCollection();
  25. //        $this->tierPricesHistory = new ArrayCollection();
  26.     }
  27.     protected function createTranslation(): ProductVariantTranslationInterface
  28.     {
  29.         return new ProductVariantTranslation();
  30.     }
  31.     public function getDescription(): ?string
  32.     {
  33.         return $this->getTranslation()->getDescription();
  34.     }
  35.     /** @ORM\Column(type="string", length=511, nullable=true) */
  36.     protected ?string $storageArea null;
  37.     /** @ORM\Column(type="string", length=511, nullable=true) */
  38.     protected ?string $eanCode null;
  39.     /** @ORM\Column(name="purchase_price", type="integer", nullable=true) */
  40.     protected ?int $purchasePrice;
  41.     /**
  42.      * @var \DateTimeInterface|null
  43.      *
  44.      * @ORM\Column(name="restocking_date", type="datetime", nullable=true)
  45.      */
  46.     protected $restockingDate;
  47.     /**
  48.      * @var \DateTimeInterface|null
  49.      *
  50.      * @ORM\Column(name="archived_at", type="datetime", nullable=true)
  51.      */
  52.     protected $archivedAt;
  53.     /**
  54.      * @ORM\OneToMany(
  55.      *   targetEntity="Brille24\SyliusTierPricePlugin\Entity\TierPriceInterface",
  56.      *   mappedBy="productVariant",
  57.      *   cascade={"all"},
  58.      *   orphanRemoval=true
  59.      * )
  60.      * @ORM\OrderBy({"customerGroup" = "ASC", "qty" = "ASC"})
  61.      */
  62.     protected $tierPrices;
  63.     /** @ORM\Column(name="unlimited_stock", type="boolean", nullable=false, options={"default" : 0}) */
  64.     protected bool $unlimitedStock false;
  65. //    /**
  66. //     * @ORM\OneToMany(
  67. //     *   targetEntity="App\Entity\PriceHistory\ChannelPricingHistory",
  68. //     *   mappedBy="owner",
  69. //     *   cascade={"all"},
  70. //     *   orphanRemoval=true
  71. //     * )
  72. //     * @ORM\OrderBy({"customerGroup" = "ASC", "qty" = "ASC"})
  73. //     */
  74. //    protected Collection $channelPricingsHistory;
  75.     /**
  76. //     * @ORM\OneToMany(
  77. //     *   targetEntity="App\Entity\PriceHistory\TierPriceHistory",
  78. //     *   mappedBy="owner",
  79. //     *   cascade={"all"},
  80. //     *   orphanRemoval=true
  81. //     * )
  82. //     * @ORM\OrderBy({"customerGroup" = "ASC", "qty" = "ASC"})
  83. //     */
  84. //    protected Collection $tierPricesHistory;
  85.     /**
  86.      * @ORM\ManyToOne(targetEntity="App\Entity\Product\ProductVariant", cascade={"persist"})
  87.      * @ORM\JoinColumn(name="alternative_variant_id", referencedColumnName="id", onDelete="SET NULL", nullable=true)
  88.      */
  89.     protected ?\Sylius\Component\Core\Model\ProductVariantInterface $alternativeVariant null;
  90.     /** @ORM\Column(type="string", length=511, nullable=true) */
  91.     protected ?string $articleCaractValPhotoId null;
  92.     public function getStorageArea(): ?string
  93.     {
  94.         return $this->storageArea;
  95.     }
  96.     public function setStorageArea(?string $storageArea): void
  97.     {
  98.         $this->storageArea $storageArea;
  99.     }
  100.     public function getEanCode(): ?string
  101.     {
  102.         return $this->eanCode;
  103.     }
  104.     public function setEanCode(?string $eanCode): void
  105.     {
  106.         $this->eanCode $eanCode;
  107.     }
  108.     public function getPurchasePrice(): ?int
  109.     {
  110.         return $this->purchasePrice;
  111.     }
  112.     public function setPurchasePrice(?int $purchasePrice): void
  113.     {
  114.         $this->purchasePrice $purchasePrice;
  115.     }
  116.     public function getArchivedAt(): ?\DateTimeInterface
  117.     {
  118.         return $this->archivedAt;
  119.     }
  120.     public function setArchivedAt(?\DateTimeInterface $archivedAt): void
  121.     {
  122.         $this->archivedAt $archivedAt;
  123.     }
  124.     /**
  125.      * Get the value of restockingDate.
  126.      */
  127.     public function getRestockingDate(): ?\DateTimeInterface
  128.     {
  129.         return $this->restockingDate;
  130.     }
  131.     /**
  132.      * Set the value of restockingDate.
  133.      *
  134.      * @return self
  135.      */
  136.     public function setRestockingDate(?\DateTimeInterface $restockingDate)
  137.     {
  138.         $this->restockingDate $restockingDate;
  139.         return $this;
  140.     }
  141. //    public function getChannelPricingsHistory(): Collection
  142. //    {
  143. //        return $this->channelPricingsHistory;
  144. //    }
  145. //
  146. //    public function addChannelPricingHistory(ChannelPricingHistory $channelPricingHistory): self
  147. //    {
  148. //        if (!$this->channelPricingsHistory->contains($channelPricingHistory)) {
  149. //            $this->channelPricingsHistory[] = $channelPricingHistory;
  150. //            $channelPricingHistory->setOwner($this);
  151. //        }
  152. //
  153. //        return $this;
  154. //    }
  155. //
  156. //    public function removeChannelPricingHistory(ChannelPricingHistory $channelPricingHistory): self
  157. //    {
  158. //        if ($this->channelPricingsHistory->removeElement($channelPricingHistory)) {
  159. //            // set the owning side to null (unless already changed)
  160. //            if ($channelPricingHistory->getOwner() === $this) {
  161. //                $channelPricingHistory->setOwner(null);
  162. //            }
  163. //        }
  164. //
  165. //        return $this;
  166. //    }
  167. //    public function getTierPricesHistory(): Collection
  168. //    {
  169. //        return $this->tierPricesHistory;
  170. //    }
  171. //
  172. //    public function addTierPriceHistory(TierPriceHistory $tierPrice): self
  173. //    {
  174. //        if (!$this->tierPricesHistory->contains($tierPrice)) {
  175. //            $this->tierPricesHistory[] = $tierPrice;
  176. //            $tierPrice->setOwner($this);
  177. //        }
  178. //
  179. //        return $this;
  180. //    }
  181. //
  182. //    public function removeTierPriceHistory(TierPriceHistory $tierPrice): self
  183. //    {
  184. //        if ($this->channelPricingsHistory->removeElement($tierPrice)) {
  185. //            // set the owning side to null (unless already changed)
  186. //            if ($tierPrice->getOwner() === $this) {
  187. //                $tierPrice->setOwner(null);
  188. //            }
  189. //        }
  190. //
  191. //        return $this;
  192. //    }
  193.     public function getAlternativeVariant(): ?\Sylius\Component\Core\Model\ProductVariantInterface
  194.     {
  195.         return $this->alternativeVariant;
  196.     }
  197.     public function setAlternativeVariant(?\Sylius\Component\Core\Model\ProductVariantInterface $alternativeVariant): void
  198.     {
  199.         $this->alternativeVariant $alternativeVariant;
  200.     }
  201.     public function isUnlimitedStock(): bool
  202.     {
  203.         return $this->unlimitedStock;
  204.     }
  205.     public function setUnlimitedStock(bool $unlimitedStock): void
  206.     {
  207.         $this->unlimitedStock $unlimitedStock;
  208.     }
  209.     public function getArticleCaractValPhotoId(): ?string
  210.     {
  211.         return $this->articleCaractValPhotoId;
  212.     }
  213.     public function setArticleCaractValPhotoId(?string $articleCaractValPhotoId): void
  214.     {
  215.         $this->articleCaractValPhotoId $articleCaractValPhotoId;
  216.     }
  217. }