src/Entity/Gos/Product.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Gos;
  3. use App\Entity\ContactSegmentationableInterface;
  4. use App\Enum\Product\ProductSourceSystem;
  5. use App\Utils\BC\Import\Mapping\ProductVariant\Creator\Spec\ProductVariantNumbersSpec;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use JMS\Serializer\Annotation as JMS;
  10. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  11. /**
  12.  * Product
  13.  *
  14.  * @ORM\Table(name="product")
  15.  * @ORM\Entity(repositoryClass="App\Repository\ProductRepository")
  16.  * @ORM\HasLifecycleCallbacks
  17.  * @Vich\Uploadable
  18.  */
  19. class Product implements ContactSegmentationableInterface
  20. {
  21.     /**
  22.      * @var int
  23.      *
  24.      * @ORM\Column(name="id", type="integer")
  25.      * @ORM\Id
  26.      * @ORM\GeneratedValue(strategy="AUTO")
  27.      */
  28.     private $id;
  29.     /**
  30.      *
  31.      * @ORM\Column(enumType="App\Enum\Product\ProductSourceSystem", length=20)
  32.      */
  33.     private ProductSourceSystem $sourceSystem ProductSourceSystem::INTERNAL;
  34.     /**
  35.      * @var bool
  36.      *
  37.      * @ORM\Column(type="boolean", options={"default":0})
  38.      */
  39.     private $isVirtual false;
  40.     /**
  41.      * @var bool
  42.      *
  43.      * @ORM\Column(type="boolean", options={"default":0}, nullable=true)
  44.      */
  45.     private $isEvent false;
  46.     /**
  47.      * @var bool
  48.      *
  49.      * @ORM\Column(type="boolean", options={"default":0})
  50.      */
  51.     private $isProductPremium false;
  52.     /**
  53.      * @var bool
  54.      *
  55.      * @ORM\Column(type="boolean", options={"default":0})
  56.      */
  57.     private $separateProduct false;
  58.     /**
  59.      * @var bool
  60.      *
  61.      * @ORM\Column(type="boolean", options={"default":0})
  62.      */
  63.     private $manualVerificationUser false;
  64.     /**
  65.      * @var string
  66.      *
  67.      * @ORM\Column(type="string", length=255)
  68.      */
  69.     private $description;
  70.     /**
  71.      * @var int
  72.      *
  73.      * @ORM\Column(type="string", length=100, nullable=true)
  74.      */
  75.     private $productNo;
  76.     /**
  77.      * @var string
  78.      *
  79.      * @ORM\Column(type="string", length=255, nullable=true)
  80.      */
  81.     private $department;
  82.     /**
  83.      * @var string
  84.      *
  85.      * @ORM\Column(type="string", length=255, nullable=true)
  86.      */
  87.     private $productState;
  88.     /**
  89.      * @var string
  90.      *
  91.      * @ORM\Column(type="string", length=255, nullable=true)
  92.      */
  93.     private $vatRate;
  94.     /**
  95.      * @ORM\Column(type="boolean", nullable=true)
  96.      */
  97.     private $discountOnline;
  98.     /**
  99.      * @ORM\Column(type="float", precision=16, scale=4, nullable=true)
  100.      */
  101.     private $discountValueOnline;
  102.     /**
  103.      * @var bool
  104.      *
  105.      * @ORM\Column(type="boolean", nullable=true)
  106.      */
  107.     private $stateIsAvailible;
  108.     /**
  109.      * @var bool
  110.      *
  111.      * @ORM\Column(type="boolean", nullable=true)
  112.      */
  113.     private $stateIsForcedReservation;
  114.     /**
  115.      * @var bool
  116.      *
  117.      * @ORM\Column(type="boolean", nullable=true)
  118.      */
  119.     private $stateIsProductTest;
  120.     /**
  121.      * @ORM\ManyToMany(targetEntity="App\Entity\Gos\ProductVariant", mappedBy="product")
  122.      */
  123.     private $productVariant;
  124.     /**
  125.      * @ORM\ManyToOne(targetEntity="App\Entity\Gos\ProductCategory", inversedBy="products")
  126.      * @ORM\JoinColumn(onDelete="SET NULL")
  127.      */
  128.     private $productCategory;
  129.     /**
  130.      * @ORM\ManyToOne(targetEntity="App\Entity\Gos\ProductGroup", inversedBy="products")
  131.      * @ORM\JoinColumn()
  132.      * @JMS\Groups({"PortalSettings"})
  133.      */
  134.     private $productGroups;
  135.     /**
  136.      * @ORM\ManyToOne(targetEntity="App\Entity\Gos\ProductType", inversedBy="products")
  137.      * @ORM\JoinColumn()
  138.      * @JMS\Groups({"PortalSettings"})
  139.      */
  140.     private $productType;
  141.     /**
  142.      * @ORM\ManyToOne(targetEntity="App\Entity\Gos\ProductGosType", inversedBy="products")
  143.      * @ORM\JoinColumn()
  144.      */
  145.     private $productGosType;
  146.     /**
  147.      * @ORM\OneToMany(targetEntity="App\Entity\Gos\ProductVariant", mappedBy="masterProduct")
  148.      */
  149.     private $masterProductVariant;
  150.     /**
  151.      * @ORM\ManyToMany(targetEntity="App\Entity\Gos\Term", mappedBy="products")
  152.      */
  153.     private $terms;
  154.     /**
  155.      * @ORM\ManyToOne(targetEntity="EventType", inversedBy="products")
  156.      * @ORM\JoinColumn()
  157.      */
  158.     private $eventType;
  159.     /**
  160.      * @ORM\Column(type="datetime")
  161.      */
  162.     private $createdAt;
  163.     /**
  164.      * @ORM\Column(type="datetime", nullable=true)
  165.      */
  166.     private $updatedAt;
  167.     /**
  168.      * @ORM\OneToOne(targetEntity="GoogleMerchantFeed", mappedBy="product")
  169.      */
  170.     private $googleMerchantFeed;
  171.     /**
  172.      * @var string
  173.      *
  174.      * @ORM\Column(type="string", length=255, nullable=true)
  175.      */
  176.     private $eventPlaceName;
  177.     /**
  178.      * @var string
  179.      *
  180.      * @ORM\Column(type="string", length=255, nullable=true)
  181.      */
  182.     private $eventPlaceDesc;
  183.     /**
  184.      * @ORM\ManyToMany(targetEntity="App\Entity\Gos\ProductAssociation", mappedBy="products", fetch="EAGER")
  185.      */
  186.     private $productAssociation;
  187.     /**
  188.      * @ORM\ManyToMany(targetEntity=ContactSegmentation::class)
  189.      */
  190.     private $contactSegmentations;
  191.     /** @ORM\PrePersist() */
  192.     public function prePersist()
  193.     {
  194.         $this->createdAt = new \DateTime();
  195.     }
  196.     /** @ORM\PreUpdate() */
  197.     public function preUpdate()
  198.     {
  199.         $this->updatedAt = new \DateTime();
  200.     }
  201.     public function __toString()
  202.     {
  203.         return empty($this->productNo) ? $this->description : (string)$this->productNo;
  204.     }
  205.     public function labelForSelect2()
  206.     {
  207.         $type = empty($this->getProductGosType()) ? 'NULL' $this->getProductGosType()->getName();
  208.         return (string)$this->productNo ' (' $this->description ')  [Type: ' $type ']';
  209.     }
  210.     public function getSourceSystem(): ProductSourceSystem
  211.     {
  212.         return $this->sourceSystem;
  213.     }
  214.     public function setSourceSystem(ProductSourceSystem $sourceSystem): void
  215.     {
  216.         $this->sourceSystem $sourceSystem;
  217.     }
  218.     public function getIsEvent(): ?bool
  219.     {
  220.         if (
  221.             !empty($this->getProductGosType())
  222.             && $this->getProductGosType()->getName() == 'event'
  223.         )
  224.         {
  225.             return true;
  226.         }
  227.         return false;
  228.     }
  229.     public function getEventStartDate()
  230.     {
  231.         $date null;
  232.         foreach ($this->getProductVariant() as $productVariant)
  233.         {
  234.             if (empty($productVariant->getEventDate())) continue;
  235.             if ($productVariant->getEventDate() < $date || $date === null)
  236.             {
  237.                 $date $productVariant->getEventDate();
  238.             }
  239.         }
  240.         return $date;
  241.     }
  242.     public function getEventDate($return 'text')
  243.     {
  244.         $date null;
  245.         /** @var ProductVariant $productVariant */
  246.         foreach ($this->getProductVariant() as $productVariant)
  247.         {
  248.             if (empty($productVariant->getEventDate()))
  249.             {
  250.                 continue;
  251.             }
  252.             $eventDate = clone $productVariant->getEventDate();
  253.             $eventDate->setTime(0,0);
  254.             if (empty($date) || $date !== $eventDate)
  255.             {
  256.                 if (is_array($date) && in_array($eventDate$date))
  257.                 {
  258.                     continue;
  259.                 }
  260.                 $date[] = $eventDate;
  261.             }
  262.         }
  263.         if ($return == 'text')
  264.         {
  265.             if (is_array($date))
  266.             {
  267.                 usort($date, function ($a$b){
  268.                     if ($a == $b) { return 0; }
  269.                     return $a $b ? -1;
  270.                 });
  271.                 if (count($date) == 1)
  272.                 {
  273.                     $date $date[0]->format('d.m.Y');
  274.                 }
  275.                 else
  276.                 {
  277.                     $date $date[0]->format('d') . '-' $date[count($date) - 1]->format('d.m.Y');
  278.                 }
  279.             }
  280.         }
  281.         elseif ($return 'json')
  282.         {
  283.             usort($date, function ($a$b){
  284.                 if ($a == $b) { return 0; }
  285.                 return $a $b ? -1;
  286.             });
  287.             $date = array($date[0]->format('Y-m-d'), $date[count($date) - 1]->format('Y-m-d'));
  288.             $date json_encode($date);
  289.         }
  290.         return $date;
  291.     }
  292.     public function getVariant($productVariantNoComplete)
  293.     {
  294.         foreach ($this->getProductVariant() as $productVariant)
  295.         {
  296.             if ($productVariant->getProductVariantNoComplete() == $productVariantNoComplete)
  297.                 return $productVariant;
  298.         }
  299.         return null;
  300.     }
  301.     public function getActiveVariants()
  302.     {
  303.         $activeVariants = new ArrayCollection();
  304.         foreach ($this->getProductVariant() as $productVariant)
  305.         {
  306.             if ($productVariant->isActive())
  307.             {
  308.                 $activeVariants->add($productVariant);
  309.             }
  310.         }
  311.         return $activeVariants;
  312.     }
  313.     /**
  314.      * Get id
  315.      *
  316.      * @return integer
  317.      */
  318.     public function getId()
  319.     {
  320.         return $this->id;
  321.     }
  322.     /**
  323.      * Set description
  324.      *
  325.      * @param string $description
  326.      *
  327.      * @return Product
  328.      */
  329.     public function setDescription($description)
  330.     {
  331.         $this->description $description;
  332.         return $this;
  333.     }
  334.     /**
  335.      * Get description
  336.      *
  337.      * @return string
  338.      */
  339.     public function getDescription()
  340.     {
  341.         return $this->description;
  342.     }
  343.     /**
  344.      * Set productNo
  345.      *
  346.      * @param integer $productNo
  347.      *
  348.      * @return Product
  349.      */
  350.     public function setProductNo($productNo)
  351.     {
  352.         $this->productNo $productNo;
  353.         return $this;
  354.     }
  355.     /**
  356.      * Get productNo
  357.      *
  358.      * @return integer
  359.      */
  360.     public function getProductNo()
  361.     {
  362.         return $this->productNo;
  363.     }
  364.     /**
  365.      * Set department
  366.      *
  367.      * @param string $department
  368.      *
  369.      * @return Product
  370.      */
  371.     public function setDepartment($department)
  372.     {
  373.         $this->department $department;
  374.         return $this;
  375.     }
  376.     /**
  377.      * Get department
  378.      *
  379.      * @return string
  380.      */
  381.     public function getDepartment()
  382.     {
  383.         return $this->department;
  384.     }
  385.     /**
  386.      * Set productState
  387.      *
  388.      * @param string $productState
  389.      *
  390.      * @return Product
  391.      */
  392.     public function setProductState($productState)
  393.     {
  394.         $this->productState $productState;
  395.         return $this;
  396.     }
  397.     /**
  398.      * Get productState
  399.      *
  400.      * @return string
  401.      */
  402.     public function getProductState()
  403.     {
  404.         return $this->productState;
  405.     }
  406.     /**
  407.      * Set vatRate
  408.      *
  409.      * @param integer $vatRate
  410.      *
  411.      * @return Product
  412.      */
  413.     public function setVatRate($vatRate)
  414.     {
  415.         $this->vatRate $vatRate;
  416.         return $this;
  417.     }
  418.     /**
  419.      * Get vatRate
  420.      *
  421.      * @return integer
  422.      */
  423.     public function getVatRate()
  424.     {
  425.         return $this->vatRate;
  426.     }
  427.     /**
  428.      * Set createdAt
  429.      *
  430.      * @param \DateTime $createdAt
  431.      *
  432.      * @return Product
  433.      */
  434.     public function setCreatedAt($createdAt)
  435.     {
  436.         $this->createdAt $createdAt;
  437.         return $this;
  438.     }
  439.     /**
  440.      * Get createdAt
  441.      *
  442.      * @return \DateTime
  443.      */
  444.     public function getCreatedAt()
  445.     {
  446.         return $this->createdAt;
  447.     }
  448.     /**
  449.      * Set updatedAt
  450.      *
  451.      * @param \DateTime $updatedAt
  452.      *
  453.      * @return Product
  454.      */
  455.     public function setUpdatedAt($updatedAt)
  456.     {
  457.         $this->updatedAt $updatedAt;
  458.         return $this;
  459.     }
  460.     /**
  461.      * Get updatedAt
  462.      *
  463.      * @return \DateTime
  464.      */
  465.     public function getUpdatedAt()
  466.     {
  467.         return $this->updatedAt;
  468.     }
  469.     /**
  470.      * Add productVariant
  471.      *
  472.      * @param \App\Entity\Gos\ProductVariant $productVariant
  473.      *
  474.      * @return Product
  475.      */
  476.     public function addProductVariant(\App\Entity\Gos\ProductVariant $productVariant)
  477.     {
  478.         if (!$this->productVariant->contains($productVariant))
  479.         {
  480.             $this->productVariant[] = $productVariant;
  481.         }
  482.         return $this;
  483.     }
  484.     /**
  485.      * Remove productVariant
  486.      *
  487.      * @param \App\Entity\Gos\ProductVariant $productVariant
  488.      */
  489.     public function removeProductVariant(\App\Entity\Gos\ProductVariant $productVariant)
  490.     {
  491.         $this->productVariant->removeElement($productVariant);
  492.     }
  493.     /**
  494.      * Get productVariant
  495.      *
  496.      * @return \Doctrine\Common\Collections\Collection
  497.      */
  498.     public function getProductVariant()
  499.     {
  500.         return $this->productVariant;
  501.     }
  502.     /**
  503.      * Set productCategory
  504.      *
  505.      * @param \App\Entity\Gos\ProductCategory $productCategory
  506.      *
  507.      * @return Product
  508.      */
  509.     public function setProductCategory(\App\Entity\Gos\ProductCategory $productCategory null)
  510.     {
  511.         $this->productCategory $productCategory;
  512.         return $this;
  513.     }
  514.     /**
  515.      * Get productCategory
  516.      *
  517.      * @return \App\Entity\Gos\ProductCategory
  518.      */
  519.     public function getProductCategory()
  520.     {
  521.         return $this->productCategory;
  522.     }
  523.     /**
  524.      * Set productGroups
  525.      *
  526.      * @param \App\Entity\Gos\ProductGroup $productGroups
  527.      *
  528.      * @return Product
  529.      */
  530.     public function setProductGroups(\App\Entity\Gos\ProductGroup $productGroups null)
  531.     {
  532.         $this->productGroups $productGroups;
  533.         return $this;
  534.     }
  535.     /**
  536.      * Get productGroups
  537.      *
  538.      * @return \App\Entity\Gos\ProductGroup
  539.      */
  540.     public function getProductGroups()
  541.     {
  542.         return $this->productGroups;
  543.     }
  544.     /**
  545.      * Set isVirtual
  546.      *
  547.      * @param boolean $isVirtual
  548.      *
  549.      * @return Product
  550.      */
  551.     public function setIsVirtual($isVirtual)
  552.     {
  553.         $this->isVirtual $isVirtual;
  554.         return $this;
  555.     }
  556.     /**
  557.      * Get isVirtual
  558.      *
  559.      * @return boolean
  560.      */
  561.     public function getIsVirtual()
  562.     {
  563.         return $this->isVirtual;
  564.     }
  565.     /**
  566.      * Set isProductPremium
  567.      *
  568.      * @param boolean $isProductPremium
  569.      *
  570.      * @return Product
  571.      */
  572.     public function setIsProductPremium($isProductPremium)
  573.     {
  574.         $this->isProductPremium $isProductPremium;
  575.         return $this;
  576.     }
  577.     /**
  578.      * Get isProductPremium
  579.      *
  580.      * @return boolean
  581.      */
  582.     public function getIsProductPremium()
  583.     {
  584.         return $this->isProductPremium;
  585.     }
  586.     /**
  587.      * Set productType
  588.      *
  589.      * @param \App\Entity\Gos\ProductType $productType
  590.      *
  591.      * @return Product
  592.      */
  593.     public function setProductType(\App\Entity\Gos\ProductType $productType null)
  594.     {
  595.         $this->productType $productType;
  596.         return $this;
  597.     }
  598.     /**
  599.      * Get productType
  600.      *
  601.      * @return \App\Entity\Gos\ProductType
  602.      */
  603.     public function getProductType()
  604.     {
  605.         return $this->productType;
  606.     }
  607.     /**
  608.      * Set discountOnline
  609.      *
  610.      * @param boolean $discountOnline
  611.      *
  612.      * @return Product
  613.      */
  614.     public function setDiscountOnline($discountOnline)
  615.     {
  616.         $this->discountOnline $discountOnline;
  617.         return $this;
  618.     }
  619.     /**
  620.      * Get discountOnline
  621.      *
  622.      * @return boolean
  623.      */
  624.     public function getDiscountOnline()
  625.     {
  626.         return $this->discountOnline;
  627.     }
  628.     /**
  629.      * Set discountValueOnline
  630.      *
  631.      * @param float $discountValueOnline
  632.      *
  633.      * @return Product
  634.      */
  635.     public function setDiscountValueOnline($discountValueOnline)
  636.     {
  637.         $this->discountValueOnline $discountValueOnline;
  638.         return $this;
  639.     }
  640.     /**
  641.      * Get discountValueOnline
  642.      *
  643.      * @return float
  644.      */
  645.     public function getDiscountValueOnline()
  646.     {
  647.         return $this->discountValueOnline;
  648.     }
  649.     /**
  650.      * Add masterProductVariant
  651.      *
  652.      * @param \App\Entity\Gos\ProductVariant $masterProductVariant
  653.      *
  654.      * @return Product
  655.      */
  656.     public function addMasterProductVariant(\App\Entity\Gos\ProductVariant $masterProductVariant)
  657.     {
  658.         $masterProductVariant->setMasterProduct($this);
  659.         $this->masterProductVariant[] = $masterProductVariant;
  660.         return $this;
  661.     }
  662.     /**
  663.      * Remove masterProductVariant
  664.      *
  665.      * @param \App\Entity\Gos\ProductVariant $masterProductVariant
  666.      */
  667.     public function removeMasterProductVariant(\App\Entity\Gos\ProductVariant $masterProductVariant)
  668.     {
  669.         $this->masterProductVariant->removeElement($masterProductVariant);
  670.     }
  671.     /**
  672.      * Get masterProductVariant
  673.      *
  674.      * @return \Doctrine\Common\Collections\Collection
  675.      */
  676.     public function getMasterProductVariant()
  677.     {
  678.         return $this->masterProductVariant;
  679.     }
  680.     /**
  681.      * Set stateIsAvailible
  682.      *
  683.      * @param boolean $stateIsAvailible
  684.      *
  685.      * @return Product
  686.      */
  687.     public function setStateIsAvailible($stateIsAvailible)
  688.     {
  689.         $this->stateIsAvailible $stateIsAvailible;
  690.         return $this;
  691.     }
  692.     /**
  693.      * Get stateIsAvailible
  694.      *
  695.      * @return boolean
  696.      */
  697.     public function getStateIsAvailible()
  698.     {
  699.         return $this->stateIsAvailible;
  700.     }
  701.     /**
  702.      * Set stateIsForcedReservation
  703.      *
  704.      * @param boolean $stateIsForcedReservation
  705.      *
  706.      * @return Product
  707.      */
  708.     public function setStateIsForcedReservation($stateIsForcedReservation)
  709.     {
  710.         $this->stateIsForcedReservation $stateIsForcedReservation;
  711.         return $this;
  712.     }
  713.     /**
  714.      * Get stateIsForcedReservation
  715.      *
  716.      * @return boolean
  717.      */
  718.     public function getStateIsForcedReservation()
  719.     {
  720.         return $this->stateIsForcedReservation;
  721.     }
  722.     /**
  723.      * Set stateIsProductTest
  724.      *
  725.      * @param boolean $stateIsProductTest
  726.      *
  727.      * @return Product
  728.      */
  729.     public function setStateIsProductTest($stateIsProductTest)
  730.     {
  731.         $this->stateIsProductTest $stateIsProductTest;
  732.         return $this;
  733.     }
  734.     /**
  735.      * Get stateIsProductTest
  736.      *
  737.      * @return boolean
  738.      */
  739.     public function getStateIsProductTest()
  740.     {
  741.         return $this->stateIsProductTest;
  742.     }
  743.     /**
  744.      * Add term
  745.      *
  746.      * @param \App\Entity\Gos\Term $term
  747.      *
  748.      * @return Product
  749.      */
  750.     public function addTerm(\App\Entity\Gos\Term $term)
  751.     {
  752.         $term->addProduct($this);
  753.         $this->terms[] = $term;
  754.         return $this;
  755.     }
  756.     /**
  757.      * Remove term
  758.      *
  759.      * @param \App\Entity\Gos\Term $term
  760.      */
  761.     public function removeTerm(\App\Entity\Gos\Term $term)
  762.     {
  763.         $term->removeProduct($this);
  764.         $this->terms->removeElement($term);
  765.     }
  766.     /**
  767.      * Get terms
  768.      *
  769.      * @return \Doctrine\Common\Collections\Collection
  770.      */
  771.     public function getTerms()
  772.     {
  773.         return $this->terms;
  774.     }
  775.     /**
  776.      * Set separateProduct
  777.      *
  778.      * @param boolean $separateProduct
  779.      *
  780.      * @return Product
  781.      */
  782.     public function setSeparateProduct($separateProduct)
  783.     {
  784.         $this->separateProduct $separateProduct;
  785.         return $this;
  786.     }
  787.     /**
  788.      * Get separateProduct
  789.      *
  790.      * @return boolean
  791.      */
  792.     public function getSeparateProduct()
  793.     {
  794.         return $this->separateProduct;
  795.     }
  796.     /**
  797.      * Set manualVerificationUser
  798.      *
  799.      * @param boolean $manualVerificationUser
  800.      *
  801.      * @return Product
  802.      */
  803.     public function setManualVerificationUser($manualVerificationUser)
  804.     {
  805.         $this->manualVerificationUser $manualVerificationUser;
  806.         return $this;
  807.     }
  808.     /**
  809.      * Get manualVerificationUser
  810.      *
  811.      * @return boolean
  812.      */
  813.     public function getManualVerificationUser()
  814.     {
  815.         return $this->manualVerificationUser;
  816.     }
  817.     /**
  818.      * Set googleMerchantFeed
  819.      *
  820.      * @param \App\Entity\Gos\GoogleMerchantFeed $googleMerchantFeed
  821.      *
  822.      * @return ProductVariant
  823.      */
  824.     public function setGoogleMerchantFeed(\App\Entity\Gos\GoogleMerchantFeed $googleMerchantFeed null)
  825.     {
  826.         $this->googleMerchantFeed $googleMerchantFeed;
  827.         return $this;
  828.     }
  829.     /**
  830.      * Get googleMerchantFeed
  831.      *
  832.      * @return \App\Entity\Gos\GoogleMerchantFeed
  833.      */
  834.     public function getGoogleMerchantFeed()
  835.     {
  836.         return $this->googleMerchantFeed;
  837.     }
  838.     /**
  839.      * Constructor
  840.      */
  841.     public function __construct()
  842.     {
  843.         $this->productVariant       = new ArrayCollection();
  844.         $this->masterProductVariant = new ArrayCollection();
  845.         $this->terms                = new ArrayCollection();
  846.         $this->productAssociation   = new ArrayCollection();
  847.         $this->contactSegmentations = new ArrayCollection();
  848.     }
  849.     public function getEventType(): ?EventType
  850.     {
  851.         return $this->eventType;
  852.     }
  853.     public function setEventType(?EventType $eventType): self
  854.     {
  855.         $this->eventType $eventType;
  856.         return $this;
  857.     }
  858.     public function getEventPlaceName(): ?string
  859.     {
  860.         return $this->eventPlaceName;
  861.     }
  862.     public function setEventPlaceName(?string $eventPlaceName): self
  863.     {
  864.         $this->eventPlaceName $eventPlaceName;
  865.         return $this;
  866.     }
  867.     public function getEventPlaceDesc(): ?string
  868.     {
  869.         return $this->eventPlaceDesc;
  870.     }
  871.     public function setEventPlaceDesc(?string $eventPlaceDesc): self
  872.     {
  873.         $this->eventPlaceDesc $eventPlaceDesc;
  874.         return $this;
  875.     }
  876.     public function getProductAssociation($id null)
  877.     {
  878.         if ($id)
  879.         {
  880.             return $this->productAssociation->filter(function($productAssociation) use ($id) {
  881.                 if ($productAssociation->getId() == $id) return $productAssociation;
  882.             })->first();
  883.         }
  884.         return $this->productAssociation;
  885.     }
  886.     public function getSingleProductAssociation()
  887.     {
  888.         return $this->productAssociation->first();
  889.     }
  890.     /**
  891.      * @param ProductAssociation $productAssociation
  892.      * @return Product
  893.      */
  894.     public function addProductAssociation(ProductAssociation $productAssociation): self
  895.     {
  896.         if (!$this->productAssociation->contains($productAssociation)) {
  897.             $this->productAssociation[] = $productAssociation;
  898.             $productAssociation->addProduct($this);
  899.         }
  900.         return $this;
  901.     }
  902.     /**
  903.      * @param ProductAssociation $productAssociation
  904.      * @return Product
  905.      */
  906.     public function removeProductAssociation(ProductAssociation $productAssociation): self
  907.     {
  908.         if ($this->productAssociation->contains($productAssociation)) {
  909.             $this->productAssociation->removeElement($productAssociation);
  910.             $productAssociation->removeProduct($this);
  911.         }
  912.         return $this;
  913.     }
  914.     public function getProductGosType(): ?ProductGosType
  915.     {
  916.         return $this->productGosType;
  917.     }
  918.     public function setProductGosType(?ProductGosType $productGosType): self
  919.     {
  920.         $this->productGosType $productGosType;
  921.         return $this;
  922.     }
  923.     public function setIsEvent(?bool $isEvent): self
  924.     {
  925.         $this->isEvent $isEvent;
  926.         return $this;
  927.     }
  928.     /**
  929.      * @return Collection|ContactSegmentation[]
  930.      */
  931.     public function getContactSegmentations(): Collection
  932.     {
  933.         return $this->contactSegmentations;
  934.     }
  935.     public function addContactSegmentation(ContactSegmentation $contactSegmentation): self
  936.     {
  937.         if (!$this->contactSegmentations->contains($contactSegmentation)) {
  938.             $this->contactSegmentations[] = $contactSegmentation;
  939.         }
  940.         return $this;
  941.     }
  942.     public function removeContactSegmentation(ContactSegmentation $contactSegmentation): self
  943.     {
  944.         if ($this->contactSegmentations->contains($contactSegmentation)) {
  945.             $this->contactSegmentations->removeElement($contactSegmentation);
  946.         }
  947.         return $this;
  948.     }
  949.     public function getSalesmanagoTags(bool $funneled false): array
  950.     {
  951.         return array_values(
  952.             $this->contactSegmentations
  953.                 ->map(function (ContactSegmentation $seg) use ($funneled) {
  954.                     $tag $seg->getSalesmanagoTag();
  955.                     if ($funneled && $tag && strncmp($tag'SEG1_'5) === 0) {
  956.                         return substr($tag5);
  957.                     }
  958.                     return $tag;
  959.                 })
  960.                 ->filter(function (?string $tag) {
  961.                     return $tag !== null && $tag !== '';
  962.                 })
  963.                 ->toArray()
  964.         );
  965.     }
  966.     public function getSalesManagoSourceTag(): ?string
  967.     {
  968.         return null;
  969.     }
  970.     public function findProductVariantByPositionType(string $positionType): ?ProductVariant
  971.     {
  972.         foreach ($this->getProductVariant() as $productVariant) {
  973.             $productVariantPositionType ProductVariantNumbersSpec::extract(
  974.                 $productVariant->getProductVariantNoComplete(), 'positionType'
  975.             );
  976.             if ($productVariantPositionType === $positionType) {
  977.                 return $productVariant;
  978.             }
  979.         }
  980.         return null;
  981.     }
  982. }