src/Entity/Product/Product.php line 15

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Product;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Sylius\Component\Core\Model\Product as BaseProduct;
  6. use Sylius\Component\Product\Model\ProductTranslationInterface;
  7. /**
  8.  * @ORM\Entity
  9.  * @ORM\Table(name="sylius_product")
  10.  */
  11. class Product extends BaseProduct
  12. {
  13.     protected function createTranslation(): ProductTranslationInterface
  14.     {
  15.         return new ProductTranslation();
  16.     }
  17.     /** @ORM\Column(type="boolean", options={"default": false}) */
  18.     protected bool $giftCard false;
  19.     /**
  20.      * @ORM\Column(type="integer", nullable=false, options={"default": 0})
  21.      */
  22.     private $orderweight;
  23.     /**
  24.      * @ORM\Column(type="integer", nullable=false, options={"default": 0})
  25.      */
  26.     private $homepageweight;
  27.     /**
  28.      * @ORM\Column(type="date", nullable=true)
  29.      */
  30.     private $datedispofrom;
  31.     /**
  32.      * @ORM\Column(type="date", nullable=true)
  33.      */
  34.     private $datedispoto;
  35.     /**
  36.      * @ORM\Column(type="text", nullable=true)
  37.      */
  38.     private $video;
  39.     public function isGiftCard(): bool
  40.     {
  41.         $taxonValue $this->getMainTaxon();
  42.         if (isset($taxonValue))
  43.         {
  44.             $root $taxonValue->getRoot();
  45.             if ($root->getCode() == "categorie" && $taxonValue->getCode() == "cadeau")
  46.                 return true;
  47.         }
  48.         return false;
  49.     }
  50.     public function setGiftCard(bool $isGiftCard): void
  51.     {
  52.         $this->giftCard $isGiftCard;
  53.     }
  54.     public function getDispoDescription(): ?string
  55.     {
  56.         return $this->getTranslation()->getDispoDescription();
  57.     }
  58.     public function getOrderweight(): ?int
  59.     {
  60.         if (is_null($this->orderweight))
  61.             return 0;
  62.         return $this->orderweight;
  63.     }
  64.     public function setOrderweight(?int $orderweight): self
  65.     {
  66.         $this->orderweight $orderweight;
  67.         return $this;
  68.     }
  69.     public function getHomePageweight(): ?int
  70.     {
  71.         if (is_null($this->homepageweight))
  72.             return 0;
  73.         return $this->homepageweight;
  74.     }
  75.     public function setHomePageweight(?int $homepageweight): self
  76.     {
  77.         $this->homepageweight $homepageweight;
  78.         return $this;
  79.     }
  80.     public function getDatedispofrom(): ?\DateTimeInterface
  81.     {
  82.         return $this->datedispofrom;
  83.     }
  84.     public function setDatedispofrom(?\DateTimeInterface $datedispofrom): self
  85.     {
  86.         $this->datedispofrom $datedispofrom;
  87.         return $this;
  88.     }
  89.     public function getDatedispoto(): ?\DateTimeInterface
  90.     {
  91.         return $this->datedispoto;
  92.     }
  93.     public function setDatedispoto(?\DateTimeInterface $datedispoto): self
  94.     {
  95.         $this->datedispoto $datedispoto;
  96.         return $this;
  97.     }
  98.     public function getVideo(): ?string
  99.     {
  100.         return $this->video;
  101.     }
  102.     public function setVideo(?string $video): self
  103.     {
  104.         $this->video $video;
  105.         return $this;
  106.     }
  107.     public function IsOrderable ()
  108.     {
  109.         $showaddtocart true;
  110.         $Datedispofrom $this->getDatedispofrom();
  111.         $Datedispoto $this->getDatedispoto();
  112.         $today =  new \DateTime("now");
  113.         $today->settime(0,0);
  114.         if (isset($Datedispofrom ) && isset($Datedispoto))
  115.         {
  116.             if (  $today $Datedispofrom  or $today $Datedispoto   )
  117.                 $showaddtocart false;
  118.         }
  119.         elseif (isset($Datedispofrom ))
  120.         {
  121.             if ( $today $Datedispofrom )
  122.                 $showaddtocart false;
  123.         }
  124.         elseif (isset($Datedispoto ))
  125.         {
  126.             if ( $today $Datedispoto )
  127.                 $showaddtocart false;
  128.         }
  129.         return $showaddtocart;
  130.     }
  131. }