src/Entity/Product.php line 33

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Knp\DoctrineBehaviors\Contract\Entity\SoftDeletableInterface;
  4. use Knp\DoctrineBehaviors\Model\SoftDeletable\SoftDeletableTrait;
  5. use Knp\DoctrineBehaviors\Model\Blameable\BlameableTrait;
  6. use Knp\DoctrineBehaviors\Contract\Entity\BlameableInterface;
  7. use Knp\DoctrineBehaviors\Model\Timestampable\TimestampableTrait;
  8. use Knp\DoctrineBehaviors\Contract\Entity\TimestampableInterface;
  9. use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait;
  10. use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
  11. use App\Model\LangParamInterface;
  12. use App\Model\LangParamRelationInterface;
  13. use Doctrine\Common\Collections\ArrayCollection;
  14. use Doctrine\Common\Collections\Collection;
  15. use Doctrine\ORM\Mapping as ORM;
  16. use Doctrine\ORM\Query\Parameter;
  17. use phpDocumentor\Reflection\Types\Self_;
  18. use Symfony\Component\Validator\Constraints as Assert;
  19. use Symfony\Component\HttpFoundation\File\UploadedFile;
  20. use Symfony\Component\HttpFoundation\File\File;
  21. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  22. /**
  23.  * @ORM\Entity
  24.  * @ORM\Table(name="product")
  25.  */
  26. class Product implements TranslatableInterfaceLangParamInterfaceBlameableInterfaceTimestampableInterfaceSoftDeletableInterface {
  27.     use BlameableTrait;
  28.     use TimestampableTrait;
  29.     use TranslatableTrait;
  30.     use SoftDeletableTrait;
  31.     const SMALL_PRODUCT_PHOTO 'smallProductPhoto';
  32.     const SMALL_PRODUCT_TEXTILE 'smallProductTextile';
  33.     const SHIPPING_CATEGORY_A 'shipping_category_a';
  34.     const SHIPPING_CATEGORY_B 'shipping_category_b';
  35.     /**
  36.      *
  37.      * Small product -> to show textiles or standard gallery product?
  38.      *
  39.      * @param $translator
  40.      * @return array
  41.      */
  42.     static public function getSmallProductOptions($translator$locale) {
  43.         return [
  44.             $translator->trans(self::SMALL_PRODUCT_PHOTO, [], 'admin'$locale) => self::SMALL_PRODUCT_PHOTO,
  45.             $translator->trans(self::SMALL_PRODUCT_TEXTILE, [], 'admin'$locale) => self::SMALL_PRODUCT_TEXTILE,
  46.         ];
  47.     }
  48.     static public function getShippingCategories($translator$locale) {
  49.         return [
  50.             $translator->trans(self::SHIPPING_CATEGORY_A, [], 'admin'$locale) => self::SHIPPING_CATEGORY_A,
  51.             $translator->trans(self::SHIPPING_CATEGORY_B, [], 'admin'$locale) => self::SHIPPING_CATEGORY_B,
  52.         ];
  53.     }
  54.     /**
  55.      * @ORM\Id
  56.      * @ORM\Column(type="integer")
  57.      * @ORM\GeneratedValue(strategy="AUTO")
  58.      */
  59.     protected $id;
  60.     /**
  61.      * Obsługa tłumaczeń
  62.      * @param $method
  63.      * @param $arguments
  64.      * @return mixed
  65.      */
  66.     public function __call($method$arguments)
  67.     {
  68.         return $this->proxyCurrentLocaleTranslation($method$arguments);
  69.     }
  70.     public function getName()
  71.     {
  72.         return $this->translate()->getName();
  73.     }
  74.     public function getDescription()
  75.     {
  76.         return $this->translate()->getDescription();
  77.     }
  78.     public function getPhoto3dGalleryUrl()
  79.     {
  80.         return $this->translate()->getPhoto3dGalleryUrl();
  81.     }
  82.     public function getYoutubeGalleryUrl()
  83.     {
  84.         return $this->translate()->getYoutubeGalleryUrl();
  85.     }
  86.     public function getMetaDescription()
  87.     {
  88.         return $this->translate()->getMetaDescription();
  89.     }
  90.     public function getMetaTitle()
  91.     {
  92.         return $this->translate()->getMetaTitle();
  93.     }
  94.     public function getMetaKeywords()
  95.     {
  96.         return $this->translate()->getMetaKeywords();
  97.     }
  98.     public function getSlug()
  99.     {
  100.         if ($this->translate()->getSlug()) {
  101.             return $this->translate()->getSlug();
  102.         } else {
  103.             return 'product';
  104.         }
  105.     }
  106.     public function getShortDescription()
  107.     {
  108.         return $this->translate()->getShortDescription();
  109.     }
  110.     public function getPhoto3dAdditional()
  111.     {
  112.         return $this->translate()->getPhoto3dAdditional();
  113.     }
  114.     public function getDetails()
  115.     {
  116.         return $this->translate()->getDetails();
  117.     }
  118.     public function getTransFilm()
  119.     {
  120.         return $this->translate()->getTransFilm();
  121.     }
  122.     public function getDescriptionFb() {
  123.         $description_facebook $this->getDescription();
  124.         $description_facebook strip_tags($description_facebook);
  125.         $description_facebook preg_replace'/\s+/'' '$description_facebook);
  126.         $description_facebook str_replace("&amp;oacute;""ó"$description_facebook);
  127.         $description_facebook str_replace("&nbsp;"" "$description_facebook);
  128.         $description_facebook str_replace("&amp;oacute;""ó"$description_facebook);
  129.         return $description_facebook;
  130.     }
  131.     /**
  132.      * @var string
  133.      *
  134.      * @ORM\Column(name="symbol", type="string", length=255, nullable=true)
  135.      */
  136.     private $symbol;
  137.     /**
  138.      * @var string
  139.      *
  140.      * @ORM\Column(name="photo3d", type="text", nullable=true)
  141.      */
  142.     private $photo3d;
  143.     /**
  144.      * @ORM\ManyToOne(targetEntity="App\Entity\ProductFamily", cascade={"all"})
  145.      * @ORM\JoinColumn(name="product_family_id", referencedColumnName="id", onDelete="CASCADE")
  146.      */
  147.     protected $productFamily;
  148.     /**
  149.      * @ORM\ManyToOne(targetEntity="App\Entity\ProductProducer", cascade={"all"})
  150.      * @ORM\JoinColumn(name="product_producer_id", referencedColumnName="id", onDelete="CASCADE")
  151.      */
  152.     protected $productProducer;
  153.     /**
  154.      * @Doctrine\ORM\Mapping\ManyToMany(targetEntity="App\Entity\Marker", inversedBy="products")
  155.      * @Doctrine\ORM\Mapping\JoinTable(name="product_markers")
  156.      */
  157.     private $markers;
  158.     /**
  159.      * @Doctrine\ORM\Mapping\ManyToMany(targetEntity="App\Entity\ProductColor", inversedBy="products")
  160.      * @Doctrine\ORM\Mapping\JoinTable(name="product_product_color")
  161.      */
  162.     private $colors;
  163.     /**
  164.      * @Doctrine\ORM\Mapping\ManyToMany(targetEntity="App\Entity\ListingMarker", inversedBy="products")
  165.      * @Doctrine\ORM\Mapping\JoinTable(name="listing_markers")
  166.      */
  167.     private $listingMarkers;
  168.     /**
  169.      * @Doctrine\ORM\Mapping\ManyToMany(targetEntity="App\Entity\ProductEquipment")
  170.      * @Doctrine\ORM\Mapping\JoinTable(name="product_equipment_relation")
  171.      */
  172.     private $equipments;
  173.     /**
  174.      * @Doctrine\ORM\Mapping\ManyToMany(targetEntity="App\Entity\DeliveryMethod")
  175.      * @Doctrine\ORM\Mapping\JoinTable(name="product_special_delivery_methods")
  176.      */
  177.     private $specialDeliveryMethods;
  178.     /**
  179.      * @ORM\ManyToOne(targetEntity="App\Entity\Availability", cascade={"all"}, inversedBy="products")
  180.      * @ORM\JoinColumn(name="availability_id", referencedColumnName="id", onDelete="CASCADE")
  181.      */
  182.     protected $availability;
  183.     /**
  184.      * @ORM\ManyToOne(targetEntity="App\Entity\Category", cascade={"all"})
  185.      * @ORM\JoinColumn(name="main_category_id", referencedColumnName="id")
  186.      */
  187.     protected $mainCategory;
  188.     /**
  189.      * @ORM\OneToMany(targetEntity="App\Entity\ProductComment", mappedBy="products", cascade={"persist"})
  190.      */
  191.     protected $comments;
  192.     /**
  193.      * @ORM\OneToMany(targetEntity="App\Entity\SubProduct", mappedBy="product", cascade={"persist"})
  194.      */
  195.     protected $subProducts;
  196.     /**
  197.      * @ORM\OneToMany(targetEntity="App\Entity\ProductFilter", mappedBy="product", cascade={"persist"})
  198.      */
  199.     protected $filters;
  200.     /**
  201.      * @Doctrine\ORM\Mapping\OneToMany(targetEntity="App\Entity\ProductPrice", mappedBy="product", cascade={"persist"})
  202.      */
  203.     protected $productPrices;
  204.     /**
  205.      * @Doctrine\ORM\Mapping\OneToMany(targetEntity="App\Entity\ProductPriceChangeLog", mappedBy="product", cascade={"persist"})
  206.      */
  207.     protected $productPriceChangeLog;
  208.     /**
  209.      * @Doctrine\ORM\Mapping\OneToMany(targetEntity="App\Entity\ProductPriceDraft", mappedBy="product", cascade={"persist"})
  210.      */
  211.     protected $productPriceDrafts;
  212.  
  213.     /**
  214.      * @Doctrine\ORM\Mapping\OneToMany(targetEntity="App\Entity\ProductXml", mappedBy="product", cascade={"persist"})
  215.      */
  216.     protected $productXml;
  217.     /**
  218.      * @Doctrine\ORM\Mapping\OneToMany(targetEntity="App\Entity\CompareParameterValue", mappedBy="product", cascade={"persist"})
  219.      * @ORM\OrderBy({"parameter" = "ASC"})
  220.      */
  221.     protected $compareValues;
  222.     /**
  223.      * @Doctrine\ORM\Mapping\OneToMany(targetEntity="App\Entity\ProductFurnitureType", mappedBy="product", cascade={"persist"})
  224.      */
  225.     protected $furnitureTypes;
  226.     /**
  227.      * @Doctrine\ORM\Mapping\OneToMany(targetEntity="App\Entity\ProductPhoto", mappedBy="product", cascade={"persist"})
  228.      * @ORM\OrderBy({"position" = "ASC"})
  229.      */
  230.     protected $photos;
  231.     /**
  232.      * @ORM\OneToMany(targetEntity="App\Entity\ProductCategory", mappedBy="product", cascade={"persist"})
  233.      */
  234.     protected $categories;
  235.     /**
  236.      * @ORM\OneToMany(targetEntity="App\Entity\ProductRecommendation", mappedBy="product", cascade={"persist"})
  237.      */
  238.     protected $recommendations;
  239.     /**
  240.      * @ORM\OneToMany(targetEntity="App\Entity\ProductSimilarColors", mappedBy="product", cascade={"persist"})
  241.      */
  242.     protected $similarColors;
  243.     /**
  244.      * @ORM\OneToMany(targetEntity="App\Entity\ProductCrossSelling", mappedBy="product", cascade={"persist"})
  245.      */
  246.     protected $crossSelling;
  247.     /**
  248.      * @ORM\OneToMany(targetEntity="App\Entity\ProductLangParam", mappedBy="product", cascade={"all"})
  249.      */
  250.     protected $langParams;
  251.     /**
  252.      * @Doctrine\ORM\Mapping\Column(name="is_variants", type="boolean", options={"default"=0}, nullable=true)
  253.      */
  254.     protected $isVariants;
  255.     /**
  256.      * @Doctrine\ORM\Mapping\Column(name="is_palette_delivery", type="boolean", options={"default"=0}, nullable=true)
  257.      */
  258.     protected $isPaletteDelivery;
  259.     /**
  260.      * @Doctrine\ORM\Mapping\Column(name="payu", type="boolean", options={"default"=0}, nullable=true)
  261.      */
  262.     protected $payu;
  263.     /**
  264.      * @Doctrine\ORM\Mapping\Column(name="automatic_price", type="boolean", options={"default"=1}, nullable=true)
  265.      */
  266.     protected $automaticPrice true;
  267.     /**
  268.      * @Doctrine\ORM\Mapping\Column(name="halmar_stock_exchange", type="boolean", options={"default"=0}, nullable=true)
  269.      */
  270.     protected $halmarStockExchange;
  271.     /**
  272.      * @Doctrine\ORM\Mapping\Column(name="diablo_stock_exchange", type="boolean", options={"default"=1}, nullable=true)
  273.      */
  274.     protected $diabloStockExchange true;
  275.     /**
  276.      * @Doctrine\ORM\Mapping\Column(name="jan_nowak_stock_exchange", type="boolean", options={"default"=1}, nullable=true)
  277.      */
  278.     protected $janNowakStockExchange true;
  279.     /**
  280.      * @Doctrine\ORM\Mapping\Column(name="actona_stock_exchange", type="boolean", options={"default"=1}, nullable=true)
  281.      */
  282.     protected $actonaStockExchange true;
  283.     /**
  284.      * @Doctrine\ORM\Mapping\Column(name="unique_stock_exchange", type="boolean", options={"default"=1}, nullable=true)
  285.      */
  286.     protected $uniqueStockExchange true;
  287.     /**
  288.      * @Doctrine\ORM\Mapping\Column(name="is_compare", type="boolean", options={"default"=0}, nullable=true)
  289.      */
  290.     protected $isCompare;
  291.     /**
  292.      * @var string
  293.      *
  294.      * @ORM\Column(name="priority_search_engine", type="integer", length=255, nullable=true)
  295.      */
  296.     private $prioritySearchEngine;
  297.     /**
  298.      * @Doctrine\ORM\Mapping\Column(name="is_negotiate", type="boolean", options={"default"=0}, nullable=true)
  299.      */
  300.     protected $isNegotiate;
  301.     /**
  302.      * @Doctrine\ORM\Mapping\Column(name="is_rebate_code", type="boolean", options={"default"=0}, nullable=true)
  303.      */
  304.     protected $isRebateCode;
  305.     /**
  306.      * @Doctrine\ORM\Mapping\Column(name="old_price", type="decimal", precision=10, scale=2, nullable=true)
  307.      */
  308.     protected $oldPrice;
  309.     /**
  310.      * DEPRECIATED - Wyłączone pole, nie używane po zmianach (film jako translatable)
  311.      * @Doctrine\ORM\Mapping\Column(name="film", type="text", nullable=true)
  312.      */
  313.     protected $film;
  314.     /**
  315.      * @Doctrine\ORM\Mapping\Column(name="small_product_photo", type="string", nullable=true)
  316.      */
  317.     protected $smallProductPhoto;
  318.     /**
  319.      * @var string
  320.      *
  321.      * @ORM\Column(name="max_quantity", type="integer", length=255, nullable=true)
  322.      */
  323.     private $maxQuantity;
  324.     /**
  325.      * @Doctrine\ORM\Mapping\ManyToMany(targetEntity="App\Entity\LandingPage", mappedBy="products")
  326.      */
  327.     private $landingPages;
  328.     /**
  329.      * @var string
  330.      *
  331.      * @ORM\Column(name="listingMarkersIds", type="text", length=255, nullable=true)
  332.      */
  333.     private $listingMarkersIds;
  334.     /**
  335.      * @Doctrine\ORM\Mapping\Column(name="temporary_unavailable", type="boolean", options={"default"=0}, nullable=true)
  336.      */
  337.     protected $temporaryUnavailable;
  338.     /**
  339.      * Cross selling - skrypt liczący ranking do wyświetlania produktów "inni kupili również"
  340.      * @var \DateTime
  341.      *
  342.      * @ORM\Column(name="last_ranking_update", type="datetime", nullable=true)
  343.      */
  344.     private $lastRankingUpdate;
  345.     /**
  346.      * @var int
  347.      *
  348.      * @ORM\Column(name="height", type="integer", length=10, nullable=true)
  349.      */
  350.     private $height;
  351.     /**
  352.      * @var int
  353.      *
  354.      * @ORM\Column(name="width", type="integer", length=10, nullable=true)
  355.      */
  356.     private $width;
  357.     /**
  358.      * @var int
  359.      *
  360.      * @ORM\Column(name="depth", type="integer", length=10, nullable=true)
  361.      */
  362.     private $depth;
  363.     /**
  364.      * @Doctrine\ORM\Mapping\Column(name="shipping_category", type="string", nullable=true, options={"default"="shipping_category_a"})
  365.      */
  366.     protected $shippingCategory self::SHIPPING_CATEGORY_A;
  367.     public $promoPrices;
  368.     public function getProductPhotos(SubProduct $subProduct null) {
  369.         $col = new ArrayCollection();
  370.         if ($subProduct and $subProduct->getImageName()) {
  371.             $sub = new ProductPhoto();
  372.             $sub->setProduct($subProduct->getProduct());
  373.             $sub->setPosition(1);
  374.             $sub->setMain(1);
  375.             $sub->setImageName($subProduct->getImageName());
  376.             $col->add($sub);
  377.         }
  378.         foreach ($this->getPhotos() as $photo) {
  379.             $photo->setMain(0);
  380.             $col->add($photo);
  381.         }
  382.         return $col;
  383.     }
  384.     /**
  385.      * Constructor
  386.      */
  387.     public function __construct()
  388.     {
  389.         $this->shippingCategory self::SHIPPING_CATEGORY_A;
  390.         $this->colors = new \Doctrine\Common\Collections\ArrayCollection();
  391.         $this->comments = new \Doctrine\Common\Collections\ArrayCollection();
  392.         $this->productPrices = new \Doctrine\Common\Collections\ArrayCollection();
  393.         $this->photos = new \Doctrine\Common\Collections\ArrayCollection();
  394.         $this->categories = new \Doctrine\Common\Collections\ArrayCollection();
  395.         $this->recommendations = new ArrayCollection();
  396.         $this->furnitureTypes = new ArrayCollection();
  397.         $this->langParams = new ArrayCollection();
  398.         $this->compareValues = new ArrayCollection();
  399.         $this->filters = new ArrayCollection();
  400.         $this->smallProductPhoto self::SMALL_PRODUCT_PHOTO;
  401.         $this->markers = new ArrayCollection();
  402.         $this->equipments = new ArrayCollection();
  403.         $this->specialDeliveryMethods = new ArrayCollection();
  404.         $this->productXml = new ArrayCollection();
  405.         $this->landingPages = new ArrayCollection();
  406.         $this->listingMarkers = new ArrayCollection();
  407.         $this->subProducts = new ArrayCollection();
  408.         $this->productPriceDrafts = new ArrayCollection();
  409.         $this->productPriceChangeLog = new ArrayCollection();
  410.         $this->crossSelling = new ArrayCollection();
  411.         $this->promoPrices = [];
  412.         $this->similarColors = new ArrayCollection();
  413.     }
  414.     public function getActiveSubProducts() {
  415.         $s = new ArrayCollection();
  416.         foreach ($this->getSubProducts() as $subProduct) {
  417.             if ($subProduct->getActive()) {
  418.                 $s->add($subProduct);
  419.             }
  420.         }
  421.         return $s;
  422.     }
  423.     public function getLandingPagesMarkers() {
  424.         $markers = new ArrayCollection();
  425.         foreach ($this->getLandingPages() as $landingPage) {
  426.             if ($landingPage->getDeletedBy() === null and $landingPage->getVisible()) {
  427.                 /** @var $marker Marker */
  428.                 foreach ($landingPage->getMarkers() as $marker) {
  429.                     $markers->add($marker);
  430.                 }
  431.             }
  432.         }
  433.         return $markers;
  434.     }
  435.     public function getActiveLandingPages() {
  436.         $lp = new ArrayCollection();
  437.         foreach ($this->getLandingPages() as $landingPage) {
  438.             if ($landingPage->getDeletedBy() === null and $landingPage->getVisible()) {
  439.                 $lp->add($landingPage);
  440.             }
  441.         }
  442.         return $lp;
  443.     }
  444.     /**
  445.      * @return string
  446.      */
  447.     public function getMaxQuantity()
  448.     {
  449.         return $this->maxQuantity;
  450.     }
  451.     /**
  452.      * @param string $maxQuantity
  453.      */
  454.     public function setMaxQuantity($maxQuantity)
  455.     {
  456.         $this->maxQuantity $maxQuantity;
  457.     }
  458.     
  459.     /**
  460.      * @return mixed
  461.      */
  462.     public function getSmallProductPhoto()
  463.     {
  464.         return $this->smallProductPhoto;
  465.     }
  466.     /**
  467.      * @param mixed $smallProductPhoto
  468.      */
  469.     public function setSmallProductPhoto($smallProductPhoto): void
  470.     {
  471.         $this->smallProductPhoto $smallProductPhoto;
  472.     }
  473.     public function mainPhotoExists($locale 'pl') {
  474.         /** @var $photo ProductPhoto */
  475.         foreach ($this->getPhotos() as $photo) {
  476.             if ($photo->getMain()) {
  477.                 /** @var $language Language */
  478.                 foreach ($photo->getLanguages() as $language) {
  479.                     if ($language->getLocaleShort() == $locale) {
  480.                         return true;
  481.                     }
  482.                 }
  483.             }
  484.         }
  485.         return false;
  486.     }
  487.     /**
  488.      * Get main picture
  489.      * @param string $locale
  490.      * @return string
  491.      */
  492.     public function getMainPhoto($locale 'pl') {
  493.         /** @var $photo ProductPhoto */
  494.         foreach ($this->getPhotos() as $photo) {
  495.             if ($photo->getMain()) {
  496.                 /** @var $language Language */
  497.                 foreach ($photo->getLanguages() as $language) {
  498.                     if ($language->getLocaleShort() == $locale) {
  499.                         return $photo->getImageName();
  500.                     }
  501.                 }
  502.             }
  503.         }
  504.         foreach ($this->getPhotos() as $photo) {
  505.             return $photo->getImageName();
  506.         }
  507.         return 'nofoto.jpg';
  508.     }
  509.     public function getOthersProductsPath($locale 'pl') {
  510.         $arr = [];
  511.         /** @var $photo ProductPhoto */
  512.         foreach ($this->getPhotos() as $photo) {
  513.             if (!$photo->getMain()) {
  514.                 /** @var $language Language */
  515.                 foreach ($photo->getLanguages() as $language) {
  516.                     if ($language->getLocaleShort() == $locale) {
  517.                         $arr[] = '/images/product/'.$photo->getImageName();
  518.                     }
  519.                 }
  520.             }
  521.         }
  522.         return $arr;
  523.     }
  524.     /**
  525.      * Gets main photo full path
  526.      * @param string $locale
  527.      * @return string
  528.      */
  529.     public function getMainPhotoPath($locale 'pl') {
  530.         return '/images/product/'.$this->getMainPhoto($locale);
  531.     }
  532.     /**
  533.      * Do not use in product lists - too many queries
  534.      * @param int $parameterId
  535.      * @return ArrayCollection
  536.      */
  537.     public function getAllVariantValues($parameterId 9) {
  538.         $values = new ArrayCollection();
  539.         /** @var $productPrice ProductPrice */
  540.         foreach ($this->getActiveProductPrices() as $productPrice) {
  541.             /** @var $variants ProductPriceVariants */
  542.             foreach ($productPrice->getVariants() as $variants) {
  543.                 if ($variants->getParameterValueGroup()) {
  544.                     foreach ($variants->getParameterValueGroup()->getVisibleValues() as $value) {
  545.                         if ($value->getParameter()->getId() == $parameterId) {
  546.                             $values->add($value);
  547.                         }
  548.                     }
  549.                 } else {
  550.                     if ($variants->getParameter()->getId() == $parameterId) {
  551.                         $values->add($variants->getParameterValue());
  552.                     }
  553.                 }
  554.             }
  555.         }
  556.         return $values;
  557.     }
  558.     public function getProductGroups() {
  559.         $groups = new ArrayCollection();
  560.         /** @var $productPrice ProductPrice */
  561.         foreach ($this->getActiveProductPrices() as $productPrice) {
  562.             /** @var $variants ProductPriceVariants */
  563.             foreach ($productPrice->getVariants() as $variants) {
  564.                 if ($variants->getParameterValueGroup() and !$groups->contains($variants->getParameterValueGroup())) {
  565.                     $groups->add($variants->getParameterValueGroup());
  566.                 }
  567.             }
  568.         }
  569.         return $groups;
  570.     }
  571.     public function getProductGroupsByParameter($parameterId) {
  572.         $groups = new ArrayCollection();
  573.         /** @var $productPrice ProductPrice */
  574.         foreach ($this->getActiveProductPrices() as $productPrice) {
  575.             /** @var $variants ProductPriceVariants */
  576.             foreach ($productPrice->getVariants() as $variants) {
  577.                 if ($variants->getParameterValueGroup() and $variants->getParameter()->getId() == $parameterId and !$groups->contains($variants->getParameterValueGroup())) {
  578.                     $groups->add($variants->getParameterValueGroup());
  579.                 }
  580.             }
  581.         }
  582.         return $groups;
  583.     }
  584.     /**
  585.      * Return array - two elements: price decimal and entity of currency
  586.      *
  587.      * @param null $currency
  588.      * @param ProductVat|null $productVat
  589.      * @return array
  590.      */
  591.     public function getPrice($currency nullProductVat $productVat null) {
  592.         if (is_object($productVat)) {
  593.             $vatRate = ($productVat->getValue()+100)/100;
  594.         } else {
  595.             $vatRate 1;
  596.         }
  597.         /** @var ProductPrice $price */
  598.         foreach ($this->getActiveProductPrices() as $price) {
  599.             if (is_object($currency) and $currency->getId() == $price->getCurrency()->getId()) {
  600.                 $returnPrice round($price->getPrice() * $vatRate,2);
  601.                 return ['price'=>$returnPrice'currency'=>$price->getCurrency()];
  602.             }
  603.         }
  604.         /** @var ProductPrice $price */
  605.         foreach ($this->getActiveProductPrices() as $price) {
  606.             if ($price->getCurrency()->getIsDefault() and $price->getCurrency()->getIsActive()) {
  607.                 $returnPrice round($price->getPrice() * $vatRate,2);
  608.                 return ['price'=>$returnPrice'currency'=>$price->getCurrency()];
  609.             }
  610.         }
  611.     }
  612.     /**
  613.      * Gets hover picture full path
  614.      * @param string $locale
  615.      * @return string
  616.      */
  617.     public function getHoverPhotoPath($locale 'pl') {
  618.         return '/images/product/'.$this->getHoverPhoto($locale);
  619.     }
  620.     /**
  621.      * Get id
  622.      *
  623.      * @return integer
  624.      */
  625.     public function getId()
  626.     {
  627.         return $this->id;
  628.     }
  629.     /**
  630.      * Set symbol
  631.      *
  632.      * @param string $symbol
  633.      *
  634.      * @return Product
  635.      */
  636.     public function setSymbol($symbol)
  637.     {
  638.         $this->symbol $symbol;
  639.         return $this;
  640.     }
  641.     /**
  642.      * Get symbol
  643.      *
  644.      * @return string
  645.      */
  646.     public function getSymbol()
  647.     {
  648.         return $this->symbol;
  649.     }
  650.     /**
  651.      * Add comment
  652.      *
  653.      * @param \App\Entity\ProductComment $comment
  654.      *
  655.      * @return Product
  656.      */
  657.     public function addComment(\App\Entity\ProductComment $comment)
  658.     {
  659.         $this->comments[] = $comment;
  660.         return $this;
  661.     }
  662.     /**
  663.      * Remove comment
  664.      *
  665.      * @param \App\Entity\ProductComment $comment
  666.      */
  667.     public function removeComment(\App\Entity\ProductComment $comment)
  668.     {
  669.         $this->comments->removeElement($comment);
  670.     }
  671.     /**
  672.      * Get comments
  673.      *
  674.      * @return \Doctrine\Common\Collections\Collection
  675.      */
  676.     public function getComments()
  677.     {
  678.         return $this->comments;
  679.     }
  680.     /**
  681.      * Add productPrice
  682.      *
  683.      * @param \App\Entity\ProductPrice $productPrice
  684.      *
  685.      * @return Product
  686.      */
  687.     public function addProductPrice(LangParamRelationInterface $productPrice)
  688.     {
  689.         $productPrice->setProduct($this);
  690.         $this->productPrices[] = $productPrice;
  691.         return $this;
  692.     }
  693.     /**
  694.      * Remove productPrice
  695.      *
  696.      * @param \App\Entity\ProductPrice $productPrice
  697.      */
  698.     public function removeProductPrice(\App\Entity\ProductPrice $productPrice)
  699.     {
  700.         $this->productPrices->removeElement($productPrice);
  701.     }
  702.     /**
  703.      * Get productPrices
  704.      *
  705.      * @return \Doctrine\Common\Collections\Collection
  706.      */
  707.     public function getActiveProductPrices()
  708.     {
  709.         $coll = new ArrayCollection();
  710.         foreach ($this->getProductPrices() as $productPrice) {
  711.             if ($productPrice->getDeletedBy() === null) {
  712.                 $coll->add($productPrice);
  713.             }
  714.         }
  715.         return $coll;
  716.     }
  717.     /**
  718.      * Get productPrices
  719.      *
  720.      * @return \Doctrine\Common\Collections\Collection
  721.      */
  722.     public function getProductPrices()
  723.     {
  724.         return $this->productPrices;
  725.     }
  726.     /**
  727.      * Add photo
  728.      *
  729.      * @param \App\Entity\ProductPhoto $photo
  730.      *
  731.      * @return Product
  732.      */
  733.     public function addPhoto(\App\Entity\ProductPhoto $photo)
  734.     {
  735.         $photo->setProduct($this);
  736.         $this->photos[] = $photo;
  737.         return $this;
  738.     }
  739.     /**
  740.      * Remove photo
  741.      *
  742.      * @param \App\Entity\ProductPhoto $photo
  743.      */
  744.     public function removePhoto(\App\Entity\ProductPhoto $photo)
  745.     {
  746.         $this->photos->removeElement($photo);
  747.     }
  748.     /**
  749.      * Get photos
  750.      *
  751.      * @return \Doctrine\Common\Collections\Collection
  752.      */
  753.     public function getPhotos()
  754.     {
  755.         return $this->photos;
  756.     }
  757.     /**
  758.      * Add category
  759.      *
  760.      * @param \App\Entity\ProductCategory $category
  761.      *
  762.      * @return Product
  763.      */
  764.     public function addCategory(\App\Entity\ProductCategory $category)
  765.     {
  766.         $this->categories[] = $category;
  767.         return $this;
  768.     }
  769.     /**
  770.      * Remove category
  771.      *
  772.      * @param \App\Entity\ProductCategory $category
  773.      */
  774.     public function removeCategory(\App\Entity\ProductCategory $category)
  775.     {
  776.         $this->categories->removeElement($category);
  777.     }
  778.     /**
  779.      * Get categories
  780.      *
  781.      * @return \Doctrine\Common\Collections\Collection
  782.      */
  783.     public function getCategories()
  784.     {
  785.         return $this->categories;
  786.     }
  787.     /**
  788.      * Add recommendation
  789.      *
  790.      * @param \App\Entity\ProductRecommendation $recommendation
  791.      *
  792.      * @return Product
  793.      */
  794.     public function addRecommendation(\App\Entity\ProductRecommendation $recommendation)
  795.     {
  796.         $recommendation->setProduct($this);
  797.         $this->recommendations[] = $recommendation;
  798.         return $this;
  799.     }
  800.     /**
  801.      * Remove recommendation
  802.      *
  803.      * @param \App\Entity\ProductRecommendation $recommendation
  804.      */
  805.     public function removeRecommendation(\App\Entity\ProductRecommendation $recommendation)
  806.     {
  807.         $this->recommendations->removeElement($recommendation);
  808.     }
  809.     /**
  810.      * Get recommendations
  811.      *
  812.      * @return \Doctrine\Common\Collections\Collection
  813.      */
  814.     public function getRecommendations()
  815.     {
  816.         return $this->recommendations;
  817.     }
  818.     public function getRecommendationsIds($locale 'pl') {
  819.         $ids = [];
  820.         /** @var $recommendation ProductRecommendation */
  821.         foreach ($this->getRecommendations() as $recommendation) {
  822.             $visible false;
  823.             foreach ($recommendation->getLanguages() as $language) {
  824.                 if ($language->getLocale() == $locale) {
  825.                     $visible true;
  826.                     break;
  827.                 }
  828.             }
  829.             if ($visible) {
  830.                 $ids[] = $recommendation->getRecommendation()->getId();
  831.             }
  832.         }
  833.         return $ids;
  834.     }
  835.     public function getSimilarColorsIds() {
  836.         $ids = [];
  837.         /** @var $recommendation ProductSimilarColors */
  838.         foreach ($this->getSimilarColors() as $recommendation) {
  839.             $ids[] = $recommendation->getSimilar()->getId();
  840.         }
  841.         return $ids;
  842.     }
  843.     public function getProductFamily(): ?ProductFamily
  844.     {
  845.         return $this->productFamily;
  846.     }
  847.     public function setProductFamily(?ProductFamily $productFamily): self
  848.     {
  849.         $this->productFamily $productFamily;
  850.         return $this;
  851.     }
  852.     /**
  853.      * @return Collection|ProductFurnitureType[]
  854.      */
  855.     public function getFurnitureTypes(): Collection
  856.     {
  857.         return $this->furnitureTypes;
  858.     }
  859.     public function addFurnitureType(ProductFurnitureType $furnitureType): self
  860.     {
  861.         if (!$this->furnitureTypes->contains($furnitureType)) {
  862.             $this->furnitureTypes[] = $furnitureType;
  863.             $furnitureType->setProduct($this);
  864.         }
  865.         return $this;
  866.     }
  867.     public function removeFurnitureType(ProductFurnitureType $furnitureType): self
  868.     {
  869.         if ($this->furnitureTypes->contains($furnitureType)) {
  870.             $this->furnitureTypes->removeElement($furnitureType);
  871.             // set the owning side to null (unless already changed)
  872.             if ($furnitureType->getProduct() === $this) {
  873.                 $furnitureType->setProduct(null);
  874.             }
  875.         }
  876.         return $this;
  877.     }
  878.     /**
  879.      * @param $locale
  880.      * @return ProductLangParam
  881.      */
  882.     public function getLangParamByLocale($locale) {
  883.         foreach ($this->getLangParams() as $langParam) {
  884.             if ($langParam->getLanguage()->getLocale() == $locale) {
  885.                 return $langParam;
  886.             }
  887.         }
  888.     }
  889.     /**
  890.      * @return Collection|ProductLangParam[]
  891.      */
  892.     public function getLangParams(): Collection
  893.     {
  894.         return $this->langParams;
  895.     }
  896.     public function addLangParam(LangParamRelationInterface $langParam): self
  897.     {
  898.         if (!$this->langParams->contains($langParam)) {
  899.             $this->langParams[] = $langParam;
  900.             $langParam->setProduct($this);
  901.         }
  902.         return $this;
  903.     }
  904.     public function removeLangParam(ProductLangParam $langParam): self
  905.     {
  906.         if ($this->langParams->contains($langParam)) {
  907.             $this->langParams->removeElement($langParam);
  908.             // set the owning side to null (unless already changed)
  909.             if ($langParam->getProduct() === $this) {
  910.                 $langParam->setProduct(null);
  911.             }
  912.         }
  913.         return $this;
  914.     }
  915.     public function getIsVariants(): ?bool
  916.     {
  917.         return $this->isVariants;
  918.     }
  919.     public function setIsVariants(?bool $isVariants): self
  920.     {
  921.         $this->isVariants $isVariants;
  922.         return $this;
  923.     }
  924.     public function getIsCompare(): ?bool
  925.     {
  926.         return $this->isCompare;
  927.     }
  928.     public function setIsCompare(?bool $isCompare): self
  929.     {
  930.         $this->isCompare $isCompare;
  931.         return $this;
  932.     }
  933.     public function getPrioritySearchEngine(): ?int
  934.     {
  935.         return $this->prioritySearchEngine;
  936.     }
  937.     public function setPrioritySearchEngine(?int $prioritySearchEngine): self
  938.     {
  939.         $this->prioritySearchEngine $prioritySearchEngine;
  940.         return $this;
  941.     }
  942.     public function getIsNegotiate(): ?bool
  943.     {
  944.         return $this->isNegotiate;
  945.     }
  946.     public function setIsNegotiate(?bool $isNegotiate): self
  947.     {
  948.         $this->isNegotiate $isNegotiate;
  949.         return $this;
  950.     }
  951.     public function getIsRebateCode(): ?bool
  952.     {
  953.         return $this->isRebateCode;
  954.     }
  955.     public function setIsRebateCode(?bool $isRebateCode): self
  956.     {
  957.         $this->isRebateCode $isRebateCode;
  958.         return $this;
  959.     }
  960.     public function setMainCategory(?Category $mainCategory): self
  961.     {
  962.         $this->mainCategory $mainCategory;
  963.         return $this;
  964.     }
  965.     public function getMainCategory(): ?Category
  966.     {
  967.         return $this->mainCategory;
  968.     }
  969.     /**
  970.      * @return Collection|CompareParameterValue[]
  971.      */
  972.     public function getCompareValues(): Collection
  973.     {
  974.         return $this->compareValues;
  975.     }
  976.     public function addCompareValue(CompareParameterValue $compareValue): self
  977.     {
  978.         if (!$this->compareValues->contains($compareValue)) {
  979.             $this->compareValues[] = $compareValue;
  980.             $compareValue->setProduct($this);
  981.         }
  982.         return $this;
  983.     }
  984.     public function removeCompareValue(CompareParameterValue $compareValue): self
  985.     {
  986.         if ($this->compareValues->contains($compareValue)) {
  987.             $this->compareValues->removeElement($compareValue);
  988.             // set the owning side to null (unless already changed)
  989.             if ($compareValue->getProduct() === $this) {
  990.                 $compareValue->setProduct(null);
  991.             }
  992.         }
  993.         return $this;
  994.     }
  995.     /**
  996.      * @return Collection|ProductFilter[]
  997.      */
  998.     public function getFilters(): Collection
  999.     {
  1000.         return $this->filters;
  1001.     }
  1002.     public function addFilter(ProductFilter $filter): self
  1003.     {
  1004.         if (!$this->filters->contains($filter)) {
  1005.             $this->filters[] = $filter;
  1006.             $filter->setProduct($this);
  1007.         }
  1008.         return $this;
  1009.     }
  1010.     public function removeFilter(ProductFilter $filter): self
  1011.     {
  1012.         if ($this->filters->contains($filter)) {
  1013.             $this->filters->removeElement($filter);
  1014.             // set the owning side to null (unless already changed)
  1015.             if ($filter->getProduct() === $this) {
  1016.                 $filter->setProduct(null);
  1017.             }
  1018.         }
  1019.         return $this;
  1020.     }
  1021.     public function getAvailability($locale 'pl')
  1022.     {
  1023.         foreach ($this->getLangParams() as $langParam) {
  1024.             if ($langParam->getLanguage()->getLocaleShort() == $locale) {
  1025.                 return $langParam->getAvailability();
  1026.             }
  1027.         }
  1028.         return null;
  1029.     }
  1030.     public function getProducer($locale 'pl')
  1031.     {
  1032.         foreach ($this->getLangParams() as $langParam) {
  1033.             if ($langParam->getLanguage()->getLocaleShort() == $locale) {
  1034.                 return $langParam->getProductProducer();
  1035.             }
  1036.         }
  1037.         return null;
  1038.     }
  1039.     public function setAvailability(?Availability $availability): self
  1040.     {
  1041.         $this->availability $availability;
  1042.         return $this;
  1043.     }
  1044.     public function getOldPrice()
  1045.     {
  1046.         return $this->oldPrice;
  1047.     }
  1048.     public function setOldPrice($oldPrice): self
  1049.     {
  1050.         $this->oldPrice $oldPrice;
  1051.         return $this;
  1052.     }
  1053.     public function getFilm()
  1054.     {
  1055.         return $this->translate()->getTransFilm();
  1056.     }
  1057.     public function getProductProducer($locale 'pl')
  1058.     {
  1059.         foreach ($this->getLangParams() as $langParam) {
  1060.             if ($langParam->getLanguage()->getLocaleShort() == $locale) {
  1061.                 return $langParam->getProductProducer();
  1062.             }
  1063.         }
  1064.         return $this->productProducer;
  1065.     }
  1066.     public function setProductProducer(?ProductProducer $productProducer): self
  1067.     {
  1068.         $this->productProducer $productProducer;
  1069.         return $this;
  1070.     }
  1071.     public function getPhoto3d(): ?string
  1072.     {
  1073.         return $this->photo3d;
  1074.     }
  1075.     public function setPhoto3d(?string $photo3d): self
  1076.     {
  1077.         $this->photo3d $photo3d;
  1078.         return $this;
  1079.     }
  1080.     /**
  1081.      * @return Collection|Marker[]
  1082.      */
  1083.     public function getMarkers(): Collection
  1084.     {
  1085.         return $this->markers;
  1086.     }
  1087.     public function addMarker(Marker $marker): self
  1088.     {
  1089.         if (!$this->markers->contains($marker)) {
  1090.             $this->markers[] = $marker;
  1091.         }
  1092.         return $this;
  1093.     }
  1094.     public function removeMarker(Marker $marker): self
  1095.     {
  1096.         if ($this->markers->contains($marker)) {
  1097.             $this->markers->removeElement($marker);
  1098.         }
  1099.         return $this;
  1100.     }
  1101.     /**
  1102.      * @return Collection|DeliveryMethod[]
  1103.      */
  1104.     public function getSpecialDeliveryMethods(): Collection
  1105.     {
  1106.         return $this->specialDeliveryMethods;
  1107.     }
  1108.     public function addSpecialDeliveryMethod(DeliveryMethod $specialDeliveryMethod): self
  1109.     {
  1110.         if (!$this->specialDeliveryMethods->contains($specialDeliveryMethod)) {
  1111.             $this->specialDeliveryMethods[] = $specialDeliveryMethod;
  1112.         }
  1113.         return $this;
  1114.     }
  1115.     public function removeSpecialDeliveryMethod(DeliveryMethod $specialDeliveryMethod): self
  1116.     {
  1117.         if ($this->specialDeliveryMethods->contains($specialDeliveryMethod)) {
  1118.             $this->specialDeliveryMethods->removeElement($specialDeliveryMethod);
  1119.         }
  1120.         return $this;
  1121.     }
  1122.     /**
  1123.      * @return Collection|ProductXml[]
  1124.      */
  1125.     public function getProductXml(): Collection
  1126.     {
  1127.         return $this->productXml;
  1128.     }
  1129.     public function addProductXml(ProductXml $productXml): self
  1130.     {
  1131.         if (!$this->productXml->contains($productXml)) {
  1132.             $this->productXml[] = $productXml;
  1133.             $productXml->setProduct($this);
  1134.         }
  1135.         return $this;
  1136.     }
  1137.     public function removeProductXml(ProductXml $productXml): self
  1138.     {
  1139.         if ($this->productXml->contains($productXml)) {
  1140.             $this->productXml->removeElement($productXml);
  1141.             // set the owning side to null (unless already changed)
  1142.             if ($productXml->getProduct() === $this) {
  1143.                 $productXml->setProduct(null);
  1144.             }
  1145.         }
  1146.         return $this;
  1147.     }
  1148.     public function getActiveEquipment() {
  1149.         $c = new ArrayCollection();
  1150.         foreach ($this->getEquipments() as $equipment) {
  1151.             if ($equipment->getDeletedBy() === null && $equipment->isVisible()) {
  1152.                 $c->add($equipment);
  1153.             }
  1154.         }
  1155.         return $c;
  1156.     }
  1157.     /**
  1158.      * @return Collection|ProductEquipment[]
  1159.      */
  1160.     public function getEquipments(): Collection
  1161.     {
  1162.         return $this->equipments;
  1163.     }
  1164.     public function addEquipment(ProductEquipment $equipment): self
  1165.     {
  1166.         if (!$this->equipments->contains($equipment)) {
  1167.             $this->equipments[] = $equipment;
  1168.         }
  1169.         return $this;
  1170.     }
  1171.     public function removeEquipment(ProductEquipment $equipment): self
  1172.     {
  1173.         if ($this->equipments->contains($equipment)) {
  1174.             $this->equipments->removeElement($equipment);
  1175.         }
  1176.         return $this;
  1177.     }
  1178.     public function getAvailableTranslations() {
  1179.         $current $this->getTranslations();
  1180.         $trans = [];
  1181.         /** @var $tran ProductTranslation */
  1182.         foreach ($current as $tran) {
  1183.             $trans[] = $tran->getLocale();
  1184.         }
  1185.         $all = ['sk''cz''pl''ro'];
  1186.         $data = [];
  1187.         foreach ($all as $lang) {
  1188.             if (in_array($lang$trans)) {
  1189.                 $data[] = ['lang'=>$lang'available'=>1];
  1190.             } else {
  1191.                 $data[] = ['lang'=>$lang'available'=>0];
  1192.             }
  1193.         }
  1194.         return $data;
  1195.     }
  1196.     public function getAvailablePrices() {
  1197.         $current $this->getActiveProductPrices();
  1198.         $trans = [];
  1199.         /** @var $tran ProductPrice */
  1200.         foreach ($current as $tran) {
  1201.             $trans[] = $tran->getLanguage()->getLocale();
  1202.         }
  1203.         $all = ['sk''cz''pl''ro'];
  1204.         $data = [];
  1205.         foreach ($all as $lang) {
  1206.             if (in_array($lang$trans)) {
  1207.                 $data[] = ['lang'=>$lang'available'=>1];
  1208.             } else {
  1209.                 $data[] = ['lang'=>$lang'available'=>0];
  1210.             }
  1211.         }
  1212.         return $data;
  1213.     }
  1214.     public function setFilm(?string $film): self
  1215.     {
  1216.         $this->film $film;
  1217.         return $this;
  1218.     }
  1219.     /**
  1220.      * @return Collection|LandingPage[]
  1221.      */
  1222.     public function getLandingPages(): Collection
  1223.     {
  1224.         return $this->landingPages;
  1225.     }
  1226.     public function addLandingPage(LandingPage $landingPage): self
  1227.     {
  1228.         if (!$this->landingPages->contains($landingPage)) {
  1229.             $this->landingPages[] = $landingPage;
  1230.             $landingPage->addProduct($this);
  1231.         }
  1232.         return $this;
  1233.     }
  1234.     public function removeLandingPage(LandingPage $landingPage): self
  1235.     {
  1236.         if ($this->landingPages->contains($landingPage)) {
  1237.             $this->landingPages->removeElement($landingPage);
  1238.             $landingPage->removeProduct($this);
  1239.         }
  1240.         return $this;
  1241.     }
  1242.     public function isSetPrice(Language $language) {
  1243.         /** @var $activeProductPrice ProductPrice */
  1244.         foreach ($this->getActiveProductPrices() as $activeProductPrice) {
  1245.             if ($activeProductPrice->getLanguage()->getId() == $language->getId()) {
  1246.                 return true;
  1247.             }
  1248.         }
  1249.         return false;
  1250.     }
  1251.     /**
  1252.      * @return Collection|Marker[]
  1253.      */
  1254.     public function getListingMarkers(): Collection
  1255.     {
  1256.         return $this->listingMarkers;
  1257.     }
  1258.     public function addListingMarker(Marker $listingMarker): self
  1259.     {
  1260.         if (!$this->listingMarkers->contains($listingMarker)) {
  1261.             $this->listingMarkers[] = $listingMarker;
  1262.         }
  1263.         return $this;
  1264.     }
  1265.     public function removeListingMarker(Marker $listingMarker): self
  1266.     {
  1267.         if ($this->listingMarkers->contains($listingMarker)) {
  1268.             $this->listingMarkers->removeElement($listingMarker);
  1269.         }
  1270.         return $this;
  1271.     }
  1272.     /**
  1273.      * @return string
  1274.      */
  1275.     public function getListingMarkersIds()
  1276.     {
  1277.         return $this->listingMarkersIds;
  1278.     }
  1279.     /**
  1280.      * @param string $listingMarkersIds
  1281.      */
  1282.     public function setListingMarkersIds($listingMarkersIds)
  1283.     {
  1284.         $this->listingMarkersIds $listingMarkersIds;
  1285.     }
  1286.     /**
  1287.      * @return mixed
  1288.      */
  1289.     public function getHalmarStockExchange()
  1290.     {
  1291.         return $this->halmarStockExchange;
  1292.     }
  1293.     /**
  1294.      * @param mixed $halmarStockExchange
  1295.      */
  1296.     public function setHalmarStockExchange($halmarStockExchange)
  1297.     {
  1298.         $this->halmarStockExchange $halmarStockExchange;
  1299.     }
  1300.     /**
  1301.      * @return Collection|SubProduct[]
  1302.      */
  1303.     public function getSubProducts(): Collection
  1304.     {
  1305.         return $this->subProducts;
  1306.     }
  1307.     public function addSubProduct(SubProduct $subProduct): self
  1308.     {
  1309.         if (!$this->subProducts->contains($subProduct)) {
  1310.             $this->subProducts[] = $subProduct;
  1311.             $subProduct->setProduct($this);
  1312.         }
  1313.         return $this;
  1314.     }
  1315.     public function removeSubProduct(SubProduct $subProduct): self
  1316.     {
  1317.         if ($this->subProducts->removeElement($subProduct)) {
  1318.             // set the owning side to null (unless already changed)
  1319.             if ($subProduct->getProduct() === $this) {
  1320.                 $subProduct->setProduct(null);
  1321.             }
  1322.         }
  1323.         return $this;
  1324.     }
  1325.     /**
  1326.      * @return bool
  1327.      */
  1328.     public function isAutomaticPrice(): bool
  1329.     {
  1330.         return $this->automaticPrice;
  1331.     }
  1332.     /**
  1333.      * @param bool $automaticPrice
  1334.      */
  1335.     public function setAutomaticPrice(bool $automaticPrice): void
  1336.     {
  1337.         $this->automaticPrice $automaticPrice;
  1338.     }
  1339.     public function getAutomaticPrice(): ?bool
  1340.     {
  1341.         return $this->automaticPrice;
  1342.     }
  1343.     /**
  1344.      * @return Collection|ProductPriceDraft[]
  1345.      */
  1346.     public function getProductPriceDrafts(): Collection
  1347.     {
  1348.         return $this->productPriceDrafts;
  1349.     }
  1350.     public function addProductPriceDraft(ProductPriceDraft $productPriceDraft): self
  1351.     {
  1352.         if (!$this->productPriceDrafts->contains($productPriceDraft)) {
  1353.             $this->productPriceDrafts[] = $productPriceDraft;
  1354.             $productPriceDraft->setProduct($this);
  1355.         }
  1356.         return $this;
  1357.     }
  1358.     public function removeProductPriceDraft(ProductPriceDraft $productPriceDraft): self
  1359.     {
  1360.         if ($this->productPriceDrafts->removeElement($productPriceDraft)) {
  1361.             // set the owning side to null (unless already changed)
  1362.             if ($productPriceDraft->getProduct() === $this) {
  1363.                 $productPriceDraft->setProduct(null);
  1364.             }
  1365.         }
  1366.         return $this;
  1367.     }
  1368.     /**
  1369.      * @return Collection|ProductPriceChangeLog[]
  1370.      */
  1371.     public function getProductPriceChangeLog(): Collection
  1372.     {
  1373.         return $this->productPriceChangeLog;
  1374.     }
  1375.     public function addProductPriceChangeLog(ProductPriceChangeLog $productPriceChangeLog): self
  1376.     {
  1377.         if (!$this->productPriceChangeLog->contains($productPriceChangeLog)) {
  1378.             $this->productPriceChangeLog[] = $productPriceChangeLog;
  1379.             $productPriceChangeLog->setProduct($this);
  1380.         }
  1381.         return $this;
  1382.     }
  1383.     public function removeProductPriceChangeLog(ProductPriceChangeLog $productPriceChangeLog): self
  1384.     {
  1385.         if ($this->productPriceChangeLog->removeElement($productPriceChangeLog)) {
  1386.             // set the owning side to null (unless already changed)
  1387.             if ($productPriceChangeLog->getProduct() === $this) {
  1388.                 $productPriceChangeLog->setProduct(null);
  1389.             }
  1390.         }
  1391.         return $this;
  1392.     }
  1393.     /**
  1394.      * @return mixed
  1395.      */
  1396.     public function getPayu()
  1397.     {
  1398.         return $this->payu;
  1399.     }
  1400.     /**
  1401.      * @param mixed $payu
  1402.      */
  1403.     public function setPayu($payu): void
  1404.     {
  1405.         $this->payu $payu;
  1406.     }
  1407.     /**
  1408.      * @return mixed
  1409.      */
  1410.     public function getTemporaryUnavailable()
  1411.     {
  1412.         return $this->temporaryUnavailable;
  1413.     }
  1414.     /**
  1415.      * @param mixed $temporaryUnavailable
  1416.      */
  1417.     public function setTemporaryUnavailable($temporaryUnavailable)
  1418.     {
  1419.         $this->temporaryUnavailable $temporaryUnavailable;
  1420.     }
  1421.     /**
  1422.      * @return Collection|ProductCrossSelling[]
  1423.      */
  1424.     public function getCrossSelling(): Collection
  1425.     {
  1426.         return $this->crossSelling;
  1427.     }
  1428.     public function addCrossSelling(ProductCrossSelling $crossSelling): self
  1429.     {
  1430.         if (!$this->crossSelling->contains($crossSelling)) {
  1431.             $this->crossSelling[] = $crossSelling;
  1432.             $crossSelling->setProduct($this);
  1433.         }
  1434.         return $this;
  1435.     }
  1436.     public function removeCrossSelling(ProductCrossSelling $crossSelling): self
  1437.     {
  1438.         if ($this->crossSelling->removeElement($crossSelling)) {
  1439.             // set the owning side to null (unless already changed)
  1440.             if ($crossSelling->getProduct() === $this) {
  1441.                 $crossSelling->setProduct(null);
  1442.             }
  1443.         }
  1444.         return $this;
  1445.     }
  1446.     /**
  1447.      * @return \DateTime
  1448.      */
  1449.     public function getLastRankingUpdate(): \DateTime
  1450.     {
  1451.         return $this->lastRankingUpdate;
  1452.     }
  1453.     /**
  1454.      * @param \DateTime $lastRankingUpdate
  1455.      */
  1456.     public function setLastRankingUpdate(\DateTime $lastRankingUpdate): void
  1457.     {
  1458.         $this->lastRankingUpdate $lastRankingUpdate;
  1459.     }
  1460.     /**
  1461.      * Add color
  1462.      *
  1463.      * @param \App\Entity\ProductColor $color
  1464.      *
  1465.      * @return Product
  1466.      */
  1467.     public function addColor(\App\Entity\ProductColor $color)
  1468.     {
  1469.         $this->colors[] = $color;
  1470.         return $this;
  1471.     }
  1472.     /**
  1473.      * Remove color
  1474.      *
  1475.      * @param \App\Entity\ProductColor $color
  1476.      */
  1477.     public function removeColor(\App\Entity\ProductColor $color)
  1478.     {
  1479.         $this->colors->removeElement($color);
  1480.     }
  1481.     /**
  1482.      * Get colors
  1483.      *
  1484.      * @return \Doctrine\Common\Collections\Collection
  1485.      */
  1486.     public function getColors()
  1487.     {
  1488.         return $this->colors;
  1489.     }
  1490.     public function getColorsIds() {
  1491.         $ids = [];
  1492.         /** @var $color ProductColor */
  1493.         foreach ($this->getColors() as $color) {
  1494.             if ($color->getDeletedBy() == null) {
  1495.                 $ids[] = $color->getId();
  1496.             }
  1497.         }
  1498.         return $ids;
  1499.     }
  1500.     /**
  1501.      * @return bool
  1502.      */
  1503.     public function isDiabloStockExchange()
  1504.     {
  1505.         return $this->diabloStockExchange;
  1506.     }
  1507.     public function getDiabloStockExchange() {
  1508.         return $this->diabloStockExchange;
  1509.     }
  1510.     /**
  1511.      * @param bool $diabloStockExchange
  1512.      */
  1513.     public function setDiabloStockExchange(bool $diabloStockExchange)
  1514.     {
  1515.         $this->diabloStockExchange $diabloStockExchange;
  1516.     }
  1517.     /**
  1518.      * @return mixed
  1519.      */
  1520.     public function getIsPaletteDelivery()
  1521.     {
  1522.         return $this->isPaletteDelivery;
  1523.     }
  1524.     /**
  1525.      * @param mixed $isPaletteDelivery
  1526.      */
  1527.     public function setIsPaletteDelivery($isPaletteDelivery)
  1528.     {
  1529.         $this->isPaletteDelivery $isPaletteDelivery;
  1530.     }
  1531.     /**
  1532.      * @return bool
  1533.      */
  1534.     public function isActonaStockExchange(): bool
  1535.     {
  1536.         return $this->actonaStockExchange;
  1537.     }
  1538.     /**
  1539.      * @param bool $actonaStockExchange
  1540.      */
  1541.     public function setActonaStockExchange(bool $actonaStockExchange): void
  1542.     {
  1543.         $this->actonaStockExchange $actonaStockExchange;
  1544.     }
  1545.     public function getActonaStockExchange(): ?bool
  1546.     {
  1547.         return $this->actonaStockExchange;
  1548.     }
  1549.     /**
  1550.      * @return bool
  1551.      */
  1552.     public function isJanNowakStockExchange(): bool
  1553.     {
  1554.         return $this->janNowakStockExchange;
  1555.     }
  1556.     /**
  1557.      * @return bool
  1558.      */
  1559.     public function getJanNowakStockExchange(): bool
  1560.     {
  1561.         return $this->janNowakStockExchange;
  1562.     }
  1563.     /**
  1564.      * @param bool $janNowakStockExchange
  1565.      */
  1566.     public function setJanNowakStockExchange(bool $janNowakStockExchange): void
  1567.     {
  1568.         $this->janNowakStockExchange $janNowakStockExchange;
  1569.     }
  1570.     /**
  1571.      * @return int
  1572.      */
  1573.     public function getHeight()
  1574.     {
  1575.         return $this->height;
  1576.     }
  1577.     /**
  1578.      * @param int $height
  1579.      */
  1580.     public function setHeight($height)
  1581.     {
  1582.         $this->height $height;
  1583.     }
  1584.     /**
  1585.      * @return int
  1586.      */
  1587.     public function getWidth()
  1588.     {
  1589.         return $this->width;
  1590.     }
  1591.     /**
  1592.      * @param int $width
  1593.      */
  1594.     public function setWidth($width)
  1595.     {
  1596.         $this->width $width;
  1597.     }
  1598.     /**
  1599.      * @return int
  1600.      */
  1601.     public function getDepth()
  1602.     {
  1603.         return $this->depth;
  1604.     }
  1605.     /**
  1606.      * @param int $depth
  1607.      */
  1608.     public function setDepth($depth)
  1609.     {
  1610.         $this->depth $depth;
  1611.     }
  1612.     /**
  1613.      * @return Collection|ProductSimilarColors[]
  1614.      */
  1615.     public function getSimilarColors(): Collection
  1616.     {
  1617.         return $this->similarColors;
  1618.     }
  1619.     public function addSimilarColor(ProductSimilarColors $similarColor): self
  1620.     {
  1621.         if (!$this->similarColors->contains($similarColor)) {
  1622.             $this->similarColors[] = $similarColor;
  1623.             $similarColor->setProduct($this);
  1624.         }
  1625.         return $this;
  1626.     }
  1627.     public function removeSimilarColor(ProductSimilarColors $similarColor): self
  1628.     {
  1629.         if ($this->similarColors->removeElement($similarColor)) {
  1630.             // set the owning side to null (unless already changed)
  1631.             if ($similarColor->getProduct() === $this) {
  1632.                 $similarColor->setProduct(null);
  1633.             }
  1634.         }
  1635.         return $this;
  1636.     }
  1637.     public function getShippingCategory(): ?string
  1638.     {
  1639.         return $this->shippingCategory;
  1640.     }
  1641.     public function setShippingCategory($shippingCategory): void
  1642.     {
  1643.         $this->shippingCategory $shippingCategory;
  1644.     }
  1645.     public function isUniqueStockExchange(): bool
  1646.     {
  1647.         return $this->uniqueStockExchange;
  1648.     }
  1649.     public function getUniqueStockExchange(): bool
  1650.     {
  1651.         return $this->uniqueStockExchange;
  1652.     }
  1653.     public function setUniqueStockExchange(bool $uniqueStockExchange): void
  1654.     {
  1655.         $this->uniqueStockExchange $uniqueStockExchange;
  1656.     }
  1657. }