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