<?php
declare(strict_types=1);
namespace App\Entity\Product;
use App\Entity\Brand\Brand;
use App\Entity\Supplier\Supplier;
use Dedi\SyliusSEOPlugin\Domain\SEO\Adapter\ReferenceableInterface;
use Dedi\SyliusSEOPlugin\Domain\SEO\Adapter\ReferenceableTrait;
use Dedi\SyliusSEOPlugin\Domain\SEO\Adapter\RichSnippetProductSubjectTrait;
use Dedi\SyliusSEOPlugin\Domain\SEO\Adapter\RichSnippetSubjectInterface;
use Dedi\SyliusSEOPlugin\Entity\SEOContent;
use Doctrine\ORM\Mapping as ORM;
use Setono\SyliusCalloutPlugin\Model\CalloutsAwareTrait as SetonoSyliusCalloutCalloutsAwareTrait;
use Setono\SyliusCalloutPlugin\Model\ProductInterface as SetonoSyliusCalloutProductInterface;
use Sylius\Component\Core\Model\Product as BaseProduct;
use Sylius\Component\Product\Model\ProductTranslationInterface;
use Sylius\Component\Resource\Model\ArchivableTrait;
/**
* @ORM\Entity
* @ORM\Table(name="sylius_product")
*/
class Product extends BaseProduct implements SetonoSyliusCalloutProductInterface, ReferenceableInterface, RichSnippetSubjectInterface
{
use RichSnippetProductSubjectTrait;
use ReferenceableTrait;
use ArchivableTrait;
use SetonoSyliusCalloutCalloutsAwareTrait {
SetonoSyliusCalloutCalloutsAwareTrait::__construct as private __calloutsTraitConstruct;
}
/**
* @ORM\Column(name="global_stock_on_hand", type="integer", options={"unsigned"=true}, nullable=true)
*/
protected ?int $globalStockOnHand = null;
/**
* @ORM\Column(name="global_stock_on_hold", type="integer", options={"unsigned"=true}, nullable=true)
*/
protected ?int $globalStockOnHold = null;
/**
* @ORM\ManyToOne(targetEntity=ProductFamily::class, inversedBy="products")
* @ORM\JoinColumn(nullable=true)
*/
private ?ProductFamily $productFamily = null;
public function __construct()
{
$this->__calloutsTraitConstruct();
parent::__construct();
}
//public function getMetadataTitle(): ?string
//{
// if (null === $this->getReferenceableContent()->getMetadataTitle()) {
// return $this->getName();
// }
//
// return $this->getBaseMetadataTitle();
//}
//
//public function getMetadataDescription(): ?string
//{
// if (!empty($this->getBaseMetadataDescription())) {
// return $this->getBaseMetadataDescription();
// }
//
// return $this->getMetaDescription();
//}
protected function createReferenceableContent(): ReferenceableInterface
{
return new SEOContent();
}
protected function createTranslation(): ProductTranslationInterface
{
return new ProductTranslation();
}
/**
* @var \DateTimeInterface|null
*
* @ORM\Column(name="archived_at", type="datetime", nullable=true)
*/
protected $archivedAt;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Supplier\Supplier")
* @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
*/
protected ?Supplier $supplier = null;
public function getSupplier(): ?Supplier
{
return $this->supplier;
}
public function setSupplier(?Supplier $supplier): void
{
$this->supplier = $supplier;
}
public function getRichSnippetSubjectParent(): ?RichSnippetSubjectInterface
{
return $this->getMainTaxon();
}
public function getRichSnippetSubjectType(): string
{
return 'product';
}
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Brand\Brand", cascade={"persist"}, fetch="EAGER", inversedBy="products")
* @ORM\JoinColumn(name="brand_id", referencedColumnName="id", onDelete="SET NULL")
*/
protected ?Brand $brand = null;
public function getBrand(): ?Brand
{
return $this->brand;
}
public function setBrand(?Brand $brand): void
{
$this->brand = $brand;
}
public function getGlobalStockOnHand(): ?int
{
return $this->globalStockOnHand;
}
public function setGlobalStockOnHand(?int $globalStockOnHand): void
{
$this->globalStockOnHand = $globalStockOnHand;
}
public function getGlobalStockOnHold(): ?int
{
return $this->globalStockOnHold;
}
public function setGlobalStockOnHold(?int $globalStockOnHold): void
{
$this->globalStockOnHold = $globalStockOnHold;
}
public function getProductFamily(): ?ProductFamily
{
return $this->productFamily;
}
public function setProductFamily(?ProductFamily $productFamily): void
{
$this->productFamily = $productFamily;
}
}