src/Entity/Product/Product.php line 25

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Product;
  4. use App\Entity\Brand\Brand;
  5. use App\Entity\Supplier\Supplier;
  6. use Dedi\SyliusSEOPlugin\Domain\SEO\Adapter\ReferenceableInterface;
  7. use Dedi\SyliusSEOPlugin\Domain\SEO\Adapter\ReferenceableTrait;
  8. use Dedi\SyliusSEOPlugin\Domain\SEO\Adapter\RichSnippetProductSubjectTrait;
  9. use Dedi\SyliusSEOPlugin\Domain\SEO\Adapter\RichSnippetSubjectInterface;
  10. use Dedi\SyliusSEOPlugin\Entity\SEOContent;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use Setono\SyliusCalloutPlugin\Model\CalloutsAwareTrait as SetonoSyliusCalloutCalloutsAwareTrait;
  13. use Setono\SyliusCalloutPlugin\Model\ProductInterface as SetonoSyliusCalloutProductInterface;
  14. use Sylius\Component\Core\Model\Product as BaseProduct;
  15. use Sylius\Component\Product\Model\ProductTranslationInterface;
  16. use Sylius\Component\Resource\Model\ArchivableTrait;
  17. /**
  18.  * @ORM\Entity
  19.  * @ORM\Table(name="sylius_product")
  20.  */
  21. class Product extends BaseProduct implements SetonoSyliusCalloutProductInterfaceReferenceableInterfaceRichSnippetSubjectInterface
  22. {
  23.     use RichSnippetProductSubjectTrait;
  24.     use ReferenceableTrait;
  25.     use ArchivableTrait;
  26.     use SetonoSyliusCalloutCalloutsAwareTrait {
  27.         SetonoSyliusCalloutCalloutsAwareTrait::__construct as private __calloutsTraitConstruct;
  28.     }
  29.     /**
  30.      * @ORM\Column(name="global_stock_on_hand", type="integer", options={"unsigned"=true}, nullable=true)
  31.      */
  32.     protected ?int $globalStockOnHand null;
  33.     /**
  34.      * @ORM\Column(name="global_stock_on_hold", type="integer", options={"unsigned"=true}, nullable=true)
  35.      */
  36.     protected ?int $globalStockOnHold null;
  37.     /**
  38.      * @ORM\ManyToOne(targetEntity=ProductFamily::class, inversedBy="products")
  39.      * @ORM\JoinColumn(nullable=true)
  40.      */
  41.     private ?ProductFamily $productFamily null;
  42.     public function __construct()
  43.     {
  44.         $this->__calloutsTraitConstruct();
  45.         parent::__construct();
  46.     }
  47.     //public function getMetadataTitle(): ?string
  48.     //{
  49.     //    if (null === $this->getReferenceableContent()->getMetadataTitle()) {
  50.     //        return $this->getName();
  51.     //    }
  52.     //
  53.     //    return $this->getBaseMetadataTitle();
  54.     //}
  55.     //
  56.     //public function getMetadataDescription(): ?string
  57.     //{
  58.     //    if (!empty($this->getBaseMetadataDescription())) {
  59.     //        return $this->getBaseMetadataDescription();
  60.     //    }
  61.     //
  62.     //    return $this->getMetaDescription();
  63.     //}
  64.     protected function createReferenceableContent(): ReferenceableInterface
  65.     {
  66.         return new SEOContent();
  67.     }
  68.     protected function createTranslation(): ProductTranslationInterface
  69.     {
  70.         return new ProductTranslation();
  71.     }
  72.     /**
  73.      * @var \DateTimeInterface|null
  74.      *
  75.      * @ORM\Column(name="archived_at", type="datetime", nullable=true)
  76.      */
  77.     protected $archivedAt;
  78.     /**
  79.      * @ORM\ManyToOne(targetEntity="App\Entity\Supplier\Supplier")
  80.      * @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
  81.      */
  82.     protected ?Supplier $supplier null;
  83.     public function getSupplier(): ?Supplier
  84.     {
  85.         return $this->supplier;
  86.     }
  87.     public function setSupplier(?Supplier $supplier): void
  88.     {
  89.         $this->supplier $supplier;
  90.     }
  91.     public function getRichSnippetSubjectParent(): ?RichSnippetSubjectInterface
  92.     {
  93.         return $this->getMainTaxon();
  94.     }
  95.     public function getRichSnippetSubjectType(): string
  96.     {
  97.         return 'product';
  98.     }
  99.     /**
  100.      * @ORM\ManyToOne(targetEntity="App\Entity\Brand\Brand", cascade={"persist"}, fetch="EAGER", inversedBy="products")
  101.      * @ORM\JoinColumn(name="brand_id", referencedColumnName="id", onDelete="SET NULL")
  102.      */
  103.     protected ?Brand $brand null;
  104.     public function getBrand(): ?Brand
  105.     {
  106.         return $this->brand;
  107.     }
  108.     public function setBrand(?Brand $brand): void
  109.     {
  110.         $this->brand $brand;
  111.     }
  112.     public function getGlobalStockOnHand(): ?int
  113.     {
  114.         return $this->globalStockOnHand;
  115.     }
  116.     public function setGlobalStockOnHand(?int $globalStockOnHand): void
  117.     {
  118.         $this->globalStockOnHand $globalStockOnHand;
  119.     }
  120.     public function getGlobalStockOnHold(): ?int
  121.     {
  122.         return $this->globalStockOnHold;
  123.     }
  124.     public function setGlobalStockOnHold(?int $globalStockOnHold): void
  125.     {
  126.         $this->globalStockOnHold $globalStockOnHold;
  127.     }
  128.     public function getProductFamily(): ?ProductFamily
  129.     {
  130.         return $this->productFamily;
  131.     }
  132.     public function setProductFamily(?ProductFamily $productFamily): void
  133.     {
  134.         $this->productFamily $productFamily;
  135.     }
  136. }