src/Entity/Product/ConfirmedProduct.php line 42

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Product;
  3. use App\Validator\Constraints as AppAssert;
  4. use App\Entity\Category;
  5. use App\Entity\CustomerGroup;
  6. use App\Entity\Label;
  7. use App\Entity\PriceHistory;
  8. use App\Entity\PriceSpecialOffer;
  9. use App\Entity\ProductSalesUnit;
  10. use App\Entity\ProductService;
  11. use App\Entity\ProductVariation;
  12. use App\Entity\Tag;
  13. use App\Entity\Unit;
  14. use Beelab\TagBundle\Tag\TaggableInterface;
  15. use Beelab\TagBundle\Tag\TagInterface;
  16. use DateTime;
  17. use DateTimeImmutable;
  18. use Doctrine\Common\Collections\ArrayCollection;
  19. use Doctrine\ORM\Mapping as ORM;
  20. use Exception;
  21. use JMS\Serializer\Annotation\Groups;
  22. use JMS\Serializer\Annotation\PreSerialize;
  23. use JMS\Serializer\Annotation\Type;
  24. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  25. use Symfony\Component\Validator\Constraints as Assert;
  26. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  27. /**
  28.  * Class ConfirmedProduct
  29.  *
  30.  * @UniqueEntity(fields={"code", "supplier"})
  31.  * @ORM\Table(name="malys_confirmed_product")
  32.  * @ORM\Entity(repositoryClass="App\Repository\ConfirmedProductRepository")
  33.  * @AppAssert\ProductPriceEmpty
  34.  * @AppAssert\ProductPricesCoherence
  35.  * @package App\Entity
  36.  * @Vich\Uploadable
  37.  */
  38. class ConfirmedProduct extends Product implements TaggableInterface {
  39.     const PROMOTION_TYPE_TO "PROMOTION_TYPE_TO"// Tarif Optimisé
  40.     const PROMOTION_TYPE_TM "PROMOTION_TYPE_TM"// Tarif Malys
  41.     const PROMOTION_TYPE_TP "PROMOTION_TYPE_TP"// Tarif Perso
  42.     /**
  43.      * @var string
  44.      * @Assert\NotBlank()
  45.      * @Groups({"api"})
  46.      */
  47.     protected $code;
  48.     /**
  49.      * @var Category
  50.      *
  51.      * @ORM\ManyToOne(targetEntity="App\Entity\Category", inversedBy="products")
  52.      * @ORM\JoinColumn(name="category_id", referencedColumnName="id", nullable=true)
  53.      * @Groups({"api"})
  54.      */
  55.     protected $category;
  56.     /**
  57.      * @var string
  58.      *
  59.      * @ORM\Column(name="sales_unit_value", type="string", length=255, nullable=true)
  60.      */
  61.     protected $salesUnitValue;
  62.     /**
  63.      *
  64.      * @var ProductSalesUnit
  65.      *
  66.      * @ORM\ManyToOne(targetEntity="App\Entity\Unit")
  67.      * @ORM\JoinColumn(name="sales_unit_id", referencedColumnName="id", nullable=true)
  68.      * @Groups({"api"})
  69.      */
  70.     protected $salesUnit;
  71.     /**
  72.      * @var string
  73.      *
  74.      * @ORM\Column(name="weight", type="string", nullable=true)
  75.      */
  76.     protected $weight;
  77.     /**
  78.      * @var string
  79.      *
  80.      * @ORM\Column(name="packaging", type="string", nullable=true)
  81.      */
  82.     protected $packaging;
  83.     /**
  84.      * @var string
  85.      *
  86.      * @ORM\Column(name="size", type="string", nullable=true)
  87.      */
  88.     protected $size;
  89.     /**
  90.      * @var float
  91.      *
  92.      * @ORM\Column(name="price_tg", type="float", nullable=true)
  93.      * @Groups({"api"})
  94.      */
  95.     protected $priceTG;
  96.     /**
  97.      * @var float
  98.      *
  99.      * @ORM\Column(name="price_tgr", type="float", nullable=true)
  100.      * @Groups({"api"})
  101.      */
  102.     protected $priceTGR;
  103.     /**
  104.      * @var float
  105.      *
  106.      * @ORM\Column(name="price_t1", type="float", nullable=true)
  107.      * @Groups({"api"})
  108.      */
  109.     protected $priceT1;
  110.     /**
  111.      * @var float
  112.      *
  113.      * @ORM\Column(name="price_t2", type="float", nullable=true)
  114.      * @Groups({"api"})
  115.      */
  116.     protected $priceT2;
  117.     /**
  118.      * @var float
  119.      *
  120.      * @ORM\Column(name="price_t3", type="float", nullable=true)
  121.      * @Groups({"api"})
  122.      */
  123.     protected $priceT3;
  124.     /**
  125.      * @var float
  126.      *
  127.      * @ORM\Column(name="price_t4", type="float", nullable=true)
  128.      * @Groups({"api"})
  129.      */
  130.     protected $priceT4;
  131.     /**
  132.      * @var float
  133.      *
  134.      * @ORM\Column(name="price_tm", type="float", nullable=true)
  135.      * @Groups({"api"})
  136.      */
  137.     protected $priceTM;
  138.     /**
  139.      * @var string
  140.      *
  141.      * @ORM\Column(name="picture", type="string", nullable=true)
  142.      */
  143.     protected $picture;
  144.     /**
  145.      * Not persisted
  146.      * @Vich\UploadableField(mapping="product_picture", fileNameProperty="picture")
  147.      * @Assert\Image(detectCorrupted=true, groups={"imageOnly", "Default"})
  148.      */
  149.     private $pictureFile;
  150.     /**
  151.   * @var string|null
  152.   * @Type("string")
  153.   * @Groups({"api"})
  154.   */
  155.  private $pictureUrl;
  156.     /**
  157.      * @var string
  158.      *
  159.      * @ORM\Column(name="fsa", type="string", length=255, nullable=true)
  160.      * @Groups({"api"})
  161.      */
  162.     protected $fsa;
  163.     /**
  164.      * @var boolean
  165.      *
  166.      * @ORM\Column(name="bio", type="boolean", options={"default" : false})
  167.      * @Groups({"api"})
  168.      */
  169.     protected $bio false;
  170.     /**
  171.      * @var boolean
  172.      *
  173.      * @ORM\Column(name="locavore", type="boolean", options={"default" : false})
  174.      */
  175.     protected $locavore false;
  176.     /**
  177.   * @var DateTime
  178.   *
  179.   * @ORM\Column(name="dluo", type="integer", nullable=true)
  180.   * @Groups({"api"})
  181.   */
  182.  protected $dluo;
  183.     /**
  184.      * @var string
  185.      *
  186.      * @ORM\Column(name="description", type="text", nullable=true)
  187.      * @Groups({"api"})
  188.      */
  189.     protected $description;
  190.     /**
  191.      * @var string
  192.      *
  193.      * @ORM\Column(name="preparation", type="text", nullable=true)
  194.      * @Groups({"api"})
  195.      */
  196.     protected $preparation;
  197.     /**
  198.      * @var string
  199.      *
  200.      * @ORM\Column(name="label", type="string", nullable=true)
  201.      */
  202.     protected $label;
  203.     /**
  204.      * @var string
  205.      *
  206.      * @ORM\Column(name="grower", type="string", nullable=true)
  207.      * @Groups({"api"})
  208.      */
  209.     protected $grower;
  210.     /**
  211.      * @var string
  212.      *
  213.      * @ORM\Column(name="origin", type="string", nullable=true)
  214.      */
  215.     protected $origin;
  216.     /**
  217.      * @var string
  218.      *
  219.      * @ORM\Column(name="more_products", type="string", nullable=true)
  220.      */
  221.     protected $moreProducts;
  222.     /**
  223.      * @var string
  224.      *
  225.      * @ORM\Column(name="brand", type="string", nullable=true)
  226.      * @Groups({"api"})
  227.      */
  228.     protected $brand;
  229.     /**
  230.      * One Product has Many Price history.
  231.      * @ORM\OneToMany(targetEntity="App\Entity\PriceHistory", mappedBy="product", cascade={"remove"})
  232.      */
  233.     protected $priceHistories;
  234.     /**
  235.   * @var DateTime
  236.   *
  237.   * @ORM\Column(name="verifiedAt", type="datetime", nullable=true)
  238.   */
  239.  protected $verifiedAt;
  240.     /**
  241.      * One Product has Many PriceOptimized
  242.      * @ORM\OneToMany(targetEntity="App\Entity\PriceOptimized", mappedBy="product", cascade={"remove"})
  243.      */
  244.     protected $optimizedPrices;
  245.     /**
  246.      * One Product has Many PriceSpecialOffer
  247.      * @ORM\OneToMany(targetEntity="App\Entity\PriceSpecialOffer", mappedBy="product", cascade={"remove"})
  248.      */
  249.     protected $specialOffers;
  250.     /**
  251.      * @var boolean
  252.      *
  253.      * * @ORM\Column(name="flash", type="boolean", options={"default" : false})
  254.      */
  255.     protected $flash false;
  256.     /**
  257.      * @var float
  258.      *
  259.      * @ORM\Column(name="price_promo", type="float", nullable=true)
  260.      */
  261.     protected $pricePromo;
  262.     /**
  263.   * @var DateTime
  264.   *
  265.   * @ORM\Column(name="date_start_validity", type="datetime", nullable=true)
  266.   */
  267.  protected $dateStartValidity;
  268.     /**
  269.   * @var DateTime
  270.   *
  271.   * @ORM\Column(name="date_end_validity", type="datetime", nullable=true)
  272.   */
  273.  protected $dateEndValidity;
  274.     /**
  275.      * @var float $bundling
  276.      * @ORM\Column(name="bundling", type="float", nullable=true, options={"default" : 1})
  277.      */
  278.     protected $bundling 1;
  279.     /**
  280.      *
  281.      * @var Unit
  282.      *
  283.      * @ORM\ManyToOne(targetEntity="App\Entity\Unit")
  284.      * @ORM\JoinColumn(name="order_unit_id", referencedColumnName="id", nullable=true)
  285.      */
  286.     protected $orderUnit;
  287.     /**
  288.      * @ORM\ManyToMany(targetEntity="App\Entity\Tag")
  289.      * @ORM\JoinTable(name="product_tag",
  290.      *     joinColumns={@ORM\JoinColumn(name="product_id", referencedColumnName="id", onDelete="cascade")}
  291.      *     )
  292.      */
  293.     private $tags;
  294.     private $tagsText;
  295.     /******************************* FIELDS FOR VIEW ******************************/
  296.     /**
  297.      * @var boolean
  298.      */
  299.     protected $calculated;
  300.     /**
  301.      * @var float
  302.      */
  303.     protected $priceProduct;
  304.     /**
  305.      * @var float
  306.      */
  307.     protected $percentagePromotion;
  308.     /**
  309.      * @var PriceSpecialOffer
  310.      */
  311.     protected $priceSpecialOffer;
  312.     /**
  313.      * @var boolean
  314.      */
  315.     protected $priceOptimized false;
  316.     /**
  317.      * @var float
  318.      */
  319.     protected $oldPrice;
  320.     /**
  321.      * One Product has Many OldPrice
  322.      * @ORM\OneToMany(targetEntity="App\Entity\OldPrice", mappedBy="product", cascade={"remove"}, orphanRemoval=true)
  323.      */
  324.     protected $oldPrices;
  325.     protected $file;
  326.     protected $promotionType null;
  327.     /**
  328.      * @ORM\ManyToMany(targetEntity="App\Entity\ProductService")
  329.      * @ORM\JoinTable(name="malys_products_services",
  330.      *     joinColumns={@ORM\JoinColumn(name="product_id", referencedColumnName="id", onDelete="cascade")}
  331.      *     )
  332.      */
  333.     protected $services;
  334.     /**
  335.      * @ORM\OneToMany(targetEntity="App\Entity\ProductVariation", mappedBy="product", cascade={"all"}, orphanRemoval=true)
  336.      * @ORM\OrderBy({"priority" = "ASC"})
  337.      * @AppAssert\ProductVariation
  338.      * @Assert\Valid
  339.      * @Groups({"api"})
  340.      */
  341.     protected $variations;
  342.     /**
  343.      * @ORM\ManyToMany(targetEntity="App\Entity\Label")
  344.      * @ORM\JoinTable(name="malys_product_label",
  345.      *     joinColumns={@ORM\JoinColumn(name="product_id", referencedColumnName="id", onDelete="cascade")}
  346.      *     )
  347.      * @Groups({"api"})
  348.      */
  349.     protected $labels;
  350.     /**
  351.      * @ORM\ManyToMany(targetEntity="App\Entity\CustomerGroup", mappedBy="mercuProducts")
  352.      * @ORM\JoinTable(name="malys_customer_groups_products")
  353.      */
  354.     protected $mercuCustomerGroups;
  355.     /**
  356.      * @var DateTime|null
  357.      * @ORM\Column(name="noveltyUntil", type="date", nullable=true)
  358.      */
  359.     protected $noveltyUntil;
  360.     // Calculated fields for ES
  361.     protected $customerRecentCount;
  362.     protected $autoUpdateDate;
  363.     /**
  364.      * Product constructor.
  365.      */
  366.     public function __construct() {
  367.         $this->priceHistories      = new ArrayCollection();
  368.         $this->optimizedPrices     = new ArrayCollection();
  369.         $this->specialOffers       = new ArrayCollection();
  370.         $this->variations          = new ArrayCollection();
  371.         $this->services            = new ArrayCollection();
  372.         $this->labels              = new ArrayCollection();
  373.         $this->mercuCustomerGroups = new ArrayCollection();
  374.         $this->tags                = new ArrayCollection();
  375.         $this->autoUpdateDate      true;
  376.     }
  377.     /**
  378.      * @PreSerialize
  379.      */
  380.     public function preSerialize() {
  381.         $this->priceTG number_format($this->priceTG3'.''');
  382.         $this->priceTGR number_format($this->priceTGR3'.''');
  383.         $this->priceTM number_format($this->priceTM3'.''');
  384.         $this->priceT1 number_format($this->priceT13'.''');
  385.         $this->priceT2 number_format($this->priceT23'.''');
  386.         $this->priceT3 number_format($this->priceT33'.''');
  387.         $this->priceT4 number_format($this->priceT43'.''');
  388.     }
  389.     /**
  390.      * @return string
  391.      */
  392.     public function getCode() {
  393.         return $this->code;
  394.     }
  395.     /**
  396.      * @param string $code
  397.      */
  398.     public function setCode$code ) {
  399.         $this->code $code;
  400.     }
  401.     /**
  402.      * @return Category
  403.      */
  404.     public function getCategory() {
  405.         return $this->category;
  406.     }
  407.     /**
  408.      * @param Category $category
  409.      */
  410.     public function setCategory$category ) {
  411.         $this->category $category;
  412.     }
  413.     /**
  414.      * @return string
  415.      */
  416.     public function getSalesUnitValue() {
  417.         return $this->salesUnitValue;
  418.     }
  419.     /**
  420.      * @param string $salesUnitValue
  421.      */
  422.     public function setSalesUnitValue$salesUnitValue ) {
  423.         $this->salesUnitValue $salesUnitValue;
  424.     }
  425.     /**
  426.      * @return ProductSalesUnit
  427.      */
  428.     public function getSalesUnit() {
  429.         return $this->salesUnit;
  430.     }
  431.     /**
  432.      * @param ProductSalesUnit $salesUnit
  433.      */
  434.     public function setSalesUnit$salesUnit ) {
  435.         $this->salesUnit $salesUnit;
  436.     }
  437.     public function getSalesUnitToString() {
  438.         $toString $this->getSalesUnitValue();
  439.         if ( $this->getSalesUnit() instanceof Unit ) {
  440.             $toString .= ' ' $this->getSalesUnit()->getLabel();
  441.         }
  442.         return $toString;
  443.     }
  444.     /**
  445.      * @return string
  446.      */
  447.     public function getWeight() {
  448.         return $this->weight;
  449.     }
  450.     /**
  451.      * @param string $weight
  452.      */
  453.     public function setWeight$weight ) {
  454.         $this->weight $weight;
  455.     }
  456.     /**
  457.      * @return string
  458.      */
  459.     public function getPackaging() {
  460.         return $this->packaging;
  461.     }
  462.     /**
  463.      * @param string $packaging
  464.      */
  465.     public function setPackaging$packaging ) {
  466.         $this->packaging $packaging;
  467.     }
  468.     /**
  469.      * @return string
  470.      */
  471.     public function getFsa() {
  472.         return $this->fsa;
  473.     }
  474.     /**
  475.      * @param string $fsa
  476.      */
  477.     public function setFsa$fsa ) {
  478.         $this->fsa $fsa;
  479.     }
  480.     /**
  481.      * @return float
  482.      */
  483.     public function getPriceTG() {
  484.         return $this->priceTG;
  485.     }
  486.     /**
  487.      * @param float $priceTG
  488.      */
  489.     public function setPriceTG$priceTG ) {
  490.         $this->priceTG $priceTG;
  491.     }
  492.     /**
  493.      * @return float
  494.      */
  495.     public function getPriceTGR() {
  496.         return $this->priceTGR;
  497.     }
  498.     /**
  499.      * @param float $priceTGR
  500.      */
  501.     public function setPriceTGR$priceTGR ) {
  502.         $this->priceTGR $priceTGR;
  503.     }
  504.     /**
  505.      * @return float
  506.      */
  507.     public function getPriceT1() {
  508.         return $this->priceT1;
  509.     }
  510.     /**
  511.      * @param float $priceT1
  512.      */
  513.     public function setPriceT1$priceT1 ) {
  514.         $this->priceT1 $priceT1;
  515.     }
  516.     /**
  517.      * @return float
  518.      */
  519.     public function getPriceT2() {
  520.         return $this->priceT2;
  521.     }
  522.     /**
  523.      * @param float $priceT2
  524.      */
  525.     public function setPriceT2$priceT2 ) {
  526.         $this->priceT2 $priceT2;
  527.     }
  528.     /**
  529.      * @return float
  530.      */
  531.     public function getPriceT3() {
  532.         return $this->priceT3;
  533.     }
  534.     /**
  535.      * @param float $priceT3
  536.      */
  537.     public function setPriceT3$priceT3 ) {
  538.         $this->priceT3 $priceT3;
  539.     }
  540.     /**
  541.      * @return float
  542.      */
  543.     public function getPriceT4() {
  544.         return $this->priceT4;
  545.     }
  546.     /**
  547.      * @param float $priceT4
  548.      */
  549.     public function setPriceT4$priceT4 ) {
  550.         $this->priceT4 $priceT4;
  551.     }
  552.     /**
  553.      * @return float
  554.      */
  555.     public function getPriceTM() {
  556.         return $this->priceTM;
  557.     }
  558.     /**
  559.      * @param float $priceTM
  560.      */
  561.     public function setPriceTM$priceTM ) {
  562.         $this->priceTM $priceTM;
  563.     }
  564.     /**
  565.      * @return string
  566.      */
  567.     public function getPicture() {
  568.         return $this->picture;
  569.     }
  570.     /**
  571.      * @param string $picture
  572.      */
  573.     public function setPicture$pictureName ) {
  574.         $this->picture $pictureName;
  575.     }
  576.     public function setPictureFile$pictureFile null ) {
  577.         $this->pictureFile $pictureFile;
  578.         if ( null !== $pictureFile ) {
  579.             $this->updatedAt = new DateTimeImmutable();
  580.         }
  581.     }
  582.     public function getPictureFile() {
  583.         return $this->pictureFile;
  584.     }
  585.     /**
  586.      * @return bool
  587.      */
  588.     public function isBio() {
  589.         return $this->bio;
  590.     }
  591.     /**
  592.      * @param bool $bio
  593.      */
  594.     public function setBio$bio ) {
  595.         $this->bio $bio;
  596.     }
  597.     /**
  598.      * @return bool
  599.      */
  600.     public function isLocavore() {
  601.         return $this->locavore;
  602.     }
  603.     /**
  604.      * @param bool $locavore
  605.      */
  606.     public function setLocavore$locavore ) {
  607.         $this->locavore $locavore;
  608.     }
  609.     /**
  610.   * @return DateTime
  611.   */
  612.  public function getDluo() {
  613.         return $this->dluo;
  614.     }
  615.     /**
  616.   * @param DateTime $dluo
  617.   */
  618.  public function setDluo$dluo ) {
  619.         $this->dluo $dluo;
  620.     }
  621.     /**
  622.      * @return string
  623.      */
  624.     public function getDescription() {
  625.         return $this->description;
  626.     }
  627.     /**
  628.      * @param string $description
  629.      */
  630.     public function setDescription$description ) {
  631.         $this->description $description;
  632.     }
  633.     /**
  634.      * @return string
  635.      */
  636.     public function getLabel() {
  637.         return $this->label;
  638.     }
  639.     /**
  640.      * @param string $label
  641.      */
  642.     public function setLabel$label ) {
  643.         $this->label $label;
  644.     }
  645.     /**
  646.      * @return float
  647.      */
  648.     public function getSize() {
  649.         return $this->size;
  650.     }
  651.     /**
  652.      * @param float $size
  653.      */
  654.     public function setSize$size ) {
  655.         $this->size $size;
  656.     }
  657.     /**
  658.      * @return string
  659.      */
  660.     public function getOrigin() {
  661.         return $this->origin;
  662.     }
  663.     /**
  664.      * @param string $origin
  665.      */
  666.     public function setOrigin$origin ) {
  667.         $this->origin $origin;
  668.     }
  669.     /**
  670.      * @return string
  671.      */
  672.     public function getMoreProducts() {
  673.         return $this->moreProducts;
  674.     }
  675.     /**
  676.      * @param string $moreProducts
  677.      */
  678.     public function setMoreProducts$moreProducts ) {
  679.         $this->moreProducts $moreProducts;
  680.     }
  681.     /**
  682.      * @return string
  683.      */
  684.     public function getBrand() {
  685.         return $this->brand;
  686.     }
  687.     /**
  688.      * @param string $brand
  689.      */
  690.     public function setBrand$brand ) {
  691.         $this->brand $brand;
  692.     }
  693.     /**
  694.      * @return string
  695.      */
  696.     public function getGrower() {
  697.         return $this->grower;
  698.     }
  699.     /**
  700.      * @param string $grower
  701.      */
  702.     public function setGrower$grower ) {
  703.         $this->grower $grower;
  704.     }
  705.     /**
  706.      * @return ArrayCollection
  707.      */
  708.     public function getPriceHistories() {
  709.         return $this->priceHistories;
  710.     }
  711.     /**
  712.      * @param ArrayCollection $priceHistories
  713.      */
  714.     public function setPriceHistories$priceHistories ) {
  715.         $this->priceHistories $priceHistories;
  716.     }
  717.     /**
  718.      * @param PriceHistory $priceHistory
  719.      */
  720.     public function addPriceHistory$priceHistory ) {
  721.         $this->priceHistories->add$priceHistory );
  722.     }
  723.     /**
  724.      * @param PriceHistory $priceHistory
  725.      */
  726.     public function removePriceHistory$priceHistory ) {
  727.         if ( ! $this->priceHistories->contains$priceHistory ) ) {
  728.             $this->priceHistories->removeElement$priceHistory );
  729.         }
  730.     }
  731.     /**
  732.      * @return mixed
  733.      */
  734.     public function getOptimizedPrices() {
  735.         return $this->optimizedPrices;
  736.     }
  737.     /**
  738.      * @param mixed $optimizedPrices
  739.      */
  740.     public function setOptimizedPrices$optimizedPrices ) {
  741.         $this->optimizedPrices $optimizedPrices;
  742.     }
  743.     /**
  744.      * @return mixed
  745.      */
  746.     public function getSpecialOffers() {
  747.         return $this->specialOffers;
  748.     }
  749.     /**
  750.      * @param mixed $specialOffers
  751.      */
  752.     public function setSpecialOffers$specialOffers ) {
  753.         $this->specialOffers $specialOffers;
  754.     }
  755.     /**
  756.      * @return bool
  757.      */
  758.     public function isCalculated() {
  759.         return $this->calculated;
  760.     }
  761.     /**
  762.      * @param bool $calculated
  763.      */
  764.     public function setCalculated$calculated ) {
  765.         $this->calculated $calculated;
  766.     }
  767.     /**
  768.   * @return float
  769.   * @throws Exception
  770.   */
  771.  public function getPriceProduct() {
  772.         if ( $this->isCalculated() ) {
  773.             return $this->priceProduct;
  774.         } else {
  775.             throw new Exception'Le montant n\'a pas été calculé BB' );
  776.         }
  777.     }
  778.     /**
  779.      * @param float $priceProduct
  780.      */
  781.     public function setPriceProduct$priceProduct ) {
  782.         $this->priceProduct $priceProduct;
  783.     }
  784.     /**
  785.   * @return float
  786.   * @throws Exception
  787.   */
  788.  public function getPercentagePromotion() {
  789.         if ( $this->isCalculated() ) {
  790.             return $this->percentagePromotion;
  791.         } else {
  792.             throw new Exception'PP Le montant n\'a pas été calculé CC' );
  793.         }
  794.     }
  795.     /**
  796.      * @param float $percentagePromotion
  797.      */
  798.     public function setPercentagePromotion$percentagePromotion ) {
  799.         $this->percentagePromotion $percentagePromotion;
  800.     }
  801.     /**
  802.      * @return bool
  803.      */
  804.     public function isPriceOptimized() {
  805.         return $this->priceOptimized;
  806.     }
  807.     /**
  808.      * @param bool $priceOptimized
  809.      */
  810.     public function setPriceOptimized$priceOptimized ) {
  811.         $this->priceOptimized $priceOptimized;
  812.     }
  813.     /**
  814.   * @return PriceSpecialOffer
  815.   * @throws Exception
  816.   */
  817.  public function getPriceSpecialOffer() {
  818.         if ( $this->isCalculated() ) {
  819.             return $this->priceSpecialOffer;
  820.         } else {
  821.             throw new Exception'Le montant n\'a pas été calculé DD' );
  822.         }
  823.     }
  824.     /**
  825.      * @param PriceSpecialOffer $priceSpecialOffer
  826.      */
  827.     public function setPriceSpecialOffer$priceSpecialOffer ) {
  828.         $this->priceSpecialOffer $priceSpecialOffer;
  829.     }
  830.     /**
  831.   * @return float
  832.   * @throws Exception
  833.   */
  834.  public function getOldPrice() {
  835.         if ( $this->isCalculated() ) {
  836.             return $this->oldPrice;
  837.         } else {
  838.             throw new Exception'Le montant n\'a pas été calculé EE' );
  839.         }
  840.     }
  841.     /**
  842.      * @param float $oldPrice
  843.      */
  844.     public function setOldPrice$oldPrice ) {
  845.         $this->oldPrice $oldPrice;
  846.     }
  847.     public function getFile() {
  848.         return $this->file;
  849.     }
  850.     public function setFile$file ) {
  851.         $this->file $file;
  852.     }
  853.     /**
  854.      * @return bool
  855.      */
  856.     public function isFlash() {
  857.         return $this->flash;
  858.     }
  859.     /**
  860.      * @param bool $flash
  861.      */
  862.     public function setFlash$flash ) {
  863.         $this->flash $flash;
  864.     }
  865.     /**
  866.      * @return float
  867.      */
  868.     public function getPricePromo() {
  869.         return $this->pricePromo;
  870.     }
  871.     /**
  872.      * @param float $pricePromo
  873.      */
  874.     public function setPricePromo$pricePromo ) {
  875.         $this->pricePromo $pricePromo;
  876.     }
  877.     /**
  878.   * @return DateTime
  879.   */
  880.  public function getDateStartValidity() {
  881.         return $this->dateStartValidity;
  882.     }
  883.     /**
  884.   * @param DateTime $dateStartValidity
  885.   */
  886.  public function setDateStartValidity$dateStartValidity ) {
  887.         $this->dateStartValidity $dateStartValidity;
  888.     }
  889.     /**
  890.   * @return DateTime
  891.   */
  892.  public function getDateEndValidity() {
  893.         return $this->dateEndValidity;
  894.     }
  895.     /**
  896.   * @param DateTime $dateEndValidity
  897.   */
  898.  public function setDateEndValidity$dateEndValidity ) {
  899.         $this->dateEndValidity $dateEndValidity;
  900.     }
  901.     /**
  902.      * @return float
  903.      */
  904.     public function getBundling() {
  905.         return $this->bundling;
  906.     }
  907.     /**
  908.      * @param float $bundling
  909.      */
  910.     public function setBundling$bundling ) {
  911.         $this->bundling $bundling;
  912.     }
  913. //    public function getPositiveBundling() {
  914. //        if ( ! empty( $this->bundling ) && $this->bundling > 0 ) {
  915. //            $bundling = $this->bundling;
  916. //        } else {
  917. //            $bundling = 1;
  918. //        }
  919. //
  920. //        return $bundling;
  921. //    }
  922.     /**
  923.      * @return mixed
  924.      */
  925.     public function getOldPrices() {
  926.         return $this->oldPrices;
  927.     }
  928.     /**
  929.      * @param mixed $oldPrices
  930.      */
  931.     public function setOldPrices$oldPrices ) {
  932.         $this->oldPrices $oldPrices;
  933.     }
  934.     /**
  935.   * @return null
  936.   * @throws Exception
  937.   */
  938.  public function getPromotionType() {
  939.         if ( $this->isCalculated() ) {
  940.             return $this->promotionType;
  941.         } else {
  942.             //throw new \Exception( 'Le montant n\'a pas été calculé FF' );
  943.         }
  944.     }
  945.     /**
  946.      * @param mixed $promotionType
  947.      */
  948.     public function setPromotionType$promotionType ) {
  949.         $this->promotionType $promotionType;
  950.     }
  951.     /**
  952.      * @return Unit
  953.      */
  954.     public function getOrderUnit() {
  955.         return $this->orderUnit;
  956.     }
  957.     /**
  958.      * @param Unit $orderUnit
  959.      */
  960.     public function setOrderUnit$orderUnit ) {
  961.         $this->orderUnit $orderUnit;
  962.     }
  963.     /**
  964.      * @return mixed
  965.      */
  966.     public function getVariations() {
  967.         return $this->variations;
  968.     }
  969.     /**
  970.      * @param mixed $variations
  971.      */
  972.     public function setVariations$variations ) {
  973.         $this->variations $variations;
  974.     }
  975.     public function addVariationProductVariation $productVariation ) {
  976.         $this->variations->add$productVariation );
  977.         $productVariation->setProduct$this );
  978.         return $this;
  979.     }
  980.     public function removeVariationProductVariation $productVariation ) {
  981.         $this->variations->removeElement$productVariation );
  982.         $productVariation->setProductnull );
  983.         return $this;
  984.     }
  985.     /**
  986.      * @return mixed
  987.      */
  988.     public function getServices() {
  989.         return $this->services;
  990.     }
  991.     /**
  992.      * @param mixed $services
  993.      */
  994.     public function setServices$services ) {
  995.         $this->services $services;
  996.     }
  997.     public function addServiceProductService $productService ) {
  998.         if ( ! $this->services->contains$productService ) ) {
  999.             $this->services->add$productService );
  1000.         }
  1001.         return $this;
  1002.     }
  1003.     public function removeServiceProductService $productService ) {
  1004.         $this->services->removeElement$productService );
  1005.         return $this;
  1006.     }
  1007.     /**
  1008.      * @return mixed
  1009.      */
  1010.     public function getCustomerRecentCount() {
  1011.         return $this->customerRecentCount;
  1012.     }
  1013.     /**
  1014.      * @param mixed $customerRecentCount
  1015.      */
  1016.     public function setCustomerRecentCount$customerRecentCount ) {
  1017.         $this->customerRecentCount $customerRecentCount;
  1018.     }
  1019.     /**
  1020.      * @return string
  1021.      */
  1022.     public function getPreparation() {
  1023.         return $this->preparation;
  1024.     }
  1025.     /**
  1026.      * @param string $preparation
  1027.      */
  1028.     public function setPreparation$preparation ) {
  1029.         $this->preparation $preparation;
  1030.     }
  1031.     /**
  1032.      * @return mixed
  1033.      */
  1034.     public function getLabels() {
  1035.         return $this->labels;
  1036.     }
  1037.     /**
  1038.      * @param mixed $labels
  1039.      */
  1040.     public function setLabels$labels ) {
  1041.         $this->labels $labels;
  1042.     }
  1043.     public function addLabelLabel $label ) {
  1044.         if ( ! $this->labels->contains$label ) ) {
  1045.             $this->labels->add$label );
  1046.         }
  1047.         return $this;
  1048.     }
  1049.     /**
  1050.   * @return DateTime
  1051.   */
  1052.  public function getVerifiedAt() {
  1053.         return $this->verifiedAt;
  1054.     }
  1055.     /**
  1056.   * @param DateTime $verifiedAt
  1057.   */
  1058.  public function setVerifiedAtDateTime $verifiedAt ) {
  1059.         $this->verifiedAt $verifiedAt;
  1060.     }
  1061.     /**
  1062.      * @return bool
  1063.      */
  1064.     public function isAutoUpdateDate(): bool {
  1065.         return $this->autoUpdateDate;
  1066.     }
  1067.     /**
  1068.      * @param bool $autoUpdateDate
  1069.      */
  1070.     public function setAutoUpdateDatebool $autoUpdateDate ) {
  1071.         $this->autoUpdateDate $autoUpdateDate;
  1072.     }
  1073.     public function addTagTagInterface $tag ): void {
  1074.         if ( ! $this->tags->contains$tag ) ) {
  1075.             $this->tags->add$tag );
  1076.         }
  1077.     }
  1078.     public function addTagNames( array $tagNamesToAdd ): void {
  1079.         $currentTagNames = [];
  1080.         $currentTags     $this->getTags();
  1081.         foreach ( $currentTags as $currentTag ) {
  1082.             $currentTagNames[] = $currentTag->getName();
  1083.         }
  1084.         foreach ( $tagNamesToAdd as $tagNameToAdd ) {
  1085.             if ( ! in_array$tagNameToAdd$currentTagNames ) ) {
  1086.                 $currentTagNames[] = trim$tagNameToAdd );
  1087.             }
  1088.         }
  1089.         $this->setTagsTextimplodeTag::DELIMITER$currentTagNames ) );
  1090.     }
  1091.     public function removeTagNames( array $tagNamesToRemove ): void {
  1092.         $currentTagNames = [];
  1093.         $currentTags     $this->getTags();
  1094.         foreach ( $currentTags as $currentTag ) {
  1095.             $currentTagNames[] = $currentTag->getName();
  1096.         }
  1097.         foreach ( $tagNamesToRemove as $tagNameToRemove ) {
  1098.             if ( ( $key array_search$tagNameToRemove$currentTagNames ) ) !== false ) {
  1099.                 unset( $currentTagNames$key ] );
  1100.             }
  1101.         }
  1102.         $this->setTagsTextimplodeTag::DELIMITER$currentTagNames ) );
  1103.     }
  1104.     public function removeTagTagInterface $tag ): void {
  1105.         $this->tags->removeElement$tag );
  1106.     }
  1107.     public function hasTagTagInterface $tag ): bool {
  1108.         return $this->tags->contains$tag );
  1109.     }
  1110.     public function getTags(): iterable {
  1111.         return $this->tags;
  1112.     }
  1113.     public function getTagNames(): array {
  1114.         return empty( $this->tagsText ) ? [] : \array_map'trim'explodeTag::DELIMITER$this->tagsText ) );
  1115.     }
  1116.     public function setTagsText( ?string $tagsText ): void {
  1117.         $this->tagsText  $tagsText;
  1118.         $this->updatedAt = new DateTime();
  1119.     }
  1120.     public function getTagsText(): ?string {
  1121.         $this->tagsText = \implodeTag::DELIMITER$this->tags->toArray() );
  1122.         return $this->tagsText;
  1123.     }
  1124.     public function getType() {
  1125.         return parent::TYPE_CONFIRMED;
  1126.     }
  1127.     /**
  1128.      * @return mixed
  1129.      */
  1130.     public function getMercuCustomerGroups() {
  1131.         return $this->mercuCustomerGroups;
  1132.     }
  1133.     /**
  1134.      * @param $mercuCustomerGroups
  1135.      */
  1136.     public function setMercuCustomerGroups$mercuCustomerGroups ) {
  1137.         $this->mercuCustomerGroups $mercuCustomerGroups;
  1138.         $this->forceUpdateAt();
  1139.     }
  1140.     public function addMercuCustomerGroupCustomerGroup $group ) {
  1141.         if ( ! $this->mercuCustomerGroups->contains$group ) ) {
  1142.             $this->mercuCustomerGroups->add$group );
  1143.             $group->addMercuProduct$this );
  1144.             $this->forceUpdateAt();
  1145.         }
  1146.         return $this;
  1147.     }
  1148.     public function removeMercuCustomerGroupCustomerGroup $group ) {
  1149.         if ( $this->mercuCustomerGroups->contains$group ) ) {
  1150.             $this->mercuCustomerGroups->removeElement$group );
  1151.             $this->forceUpdateAt();
  1152.             $group->removeMercuProduct$this );
  1153.         }
  1154.         return $this;
  1155.     }
  1156.     public function forceUpdateAt() {
  1157.         $this->setUpdatedAt( new DateTime() );
  1158.     }
  1159.     /**
  1160.      * @return null|DateTime
  1161.      */
  1162.     public function getNoveltyUntil(): ?DateTime {
  1163.         return $this->noveltyUntil;
  1164.     }
  1165.     /**
  1166.      * @param DateTime $noveltyUntil
  1167.      */
  1168.     public function setNoveltyUntil( ?DateTime $noveltyUntil ): void {
  1169.         if ( $noveltyUntil instanceof DateTime ) {
  1170.             $noveltyUntil->setTime235959 );
  1171.         }
  1172.         $this->noveltyUntil $noveltyUntil;
  1173.     }
  1174.     /**
  1175.      * @return string|null
  1176.      */
  1177.     public function getPictureUrl(): ?string
  1178.     {
  1179.         return $this->pictureUrl;
  1180.     }
  1181.     /**
  1182.      * @param string|null $pictureUrl
  1183.      */
  1184.     public function setPictureUrl(?string $pictureUrl): void
  1185.     {
  1186.         $this->pictureUrl $pictureUrl;
  1187.     }
  1188. }