<?phpdeclare(strict_types=1);namespace App\Entity\Product;use Doctrine\ORM\Mapping as ORM;use Sylius\Component\Core\Model\Product as BaseProduct;use Sylius\Component\Product\Model\ProductTranslationInterface;/** * @ORM\Entity * @ORM\Table(name="sylius_product") */class Product extends BaseProduct{ protected function createTranslation(): ProductTranslationInterface { return new ProductTranslation(); } /** @ORM\Column(type="boolean", options={"default": false}) */ protected bool $giftCard = false; /** * @ORM\Column(type="integer", nullable=false, options={"default": 0}) */ private $orderweight; /** * @ORM\Column(type="integer", nullable=false, options={"default": 0}) */ private $homepageweight; /** * @ORM\Column(type="date", nullable=true) */ private $datedispofrom; /** * @ORM\Column(type="date", nullable=true) */ private $datedispoto; /** * @ORM\Column(type="text", nullable=true) */ private $video; public function isGiftCard(): bool { $taxonValue = $this->getMainTaxon(); if (isset($taxonValue)) { $root = $taxonValue->getRoot(); if ($root->getCode() == "categorie" && $taxonValue->getCode() == "cadeau") return true; } return false; } public function setGiftCard(bool $isGiftCard): void { $this->giftCard = $isGiftCard; } public function getDispoDescription(): ?string { return $this->getTranslation()->getDispoDescription(); } public function getOrderweight(): ?int { if (is_null($this->orderweight)) return 0; return $this->orderweight; } public function setOrderweight(?int $orderweight): self { $this->orderweight = $orderweight; return $this; } public function getHomePageweight(): ?int { if (is_null($this->homepageweight)) return 0; return $this->homepageweight; } public function setHomePageweight(?int $homepageweight): self { $this->homepageweight = $homepageweight; return $this; } public function getDatedispofrom(): ?\DateTimeInterface { return $this->datedispofrom; } public function setDatedispofrom(?\DateTimeInterface $datedispofrom): self { $this->datedispofrom = $datedispofrom; return $this; } public function getDatedispoto(): ?\DateTimeInterface { return $this->datedispoto; } public function setDatedispoto(?\DateTimeInterface $datedispoto): self { $this->datedispoto = $datedispoto; return $this; } public function getVideo(): ?string { return $this->video; } public function setVideo(?string $video): self { $this->video = $video; return $this; } public function IsOrderable () { $showaddtocart = true; $Datedispofrom = $this->getDatedispofrom(); $Datedispoto = $this->getDatedispoto(); $today = new \DateTime("now"); $today->settime(0,0); if (isset($Datedispofrom ) && isset($Datedispoto)) { if ( $today < $Datedispofrom or $today > $Datedispoto ) $showaddtocart = false; } elseif (isset($Datedispofrom )) { if ( $today < $Datedispofrom ) $showaddtocart = false; } elseif (isset($Datedispoto )) { if ( $today > $Datedispoto ) $showaddtocart = false; } return $showaddtocart; }}