src/Eccube/Entity/Product.php line 30

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  6.  *
  7.  * http://www.ec-cube.co.jp/
  8.  *
  9.  * For the full copyright and license information, please view the LICENSE
  10.  * file that was distributed with this source code.
  11.  */
  12. namespace Eccube\Entity;
  13. use Doctrine\Common\Collections\ArrayCollection;
  14. use Doctrine\ORM\Mapping as ORM;
  15. use Eccube\Entity\ProductMakerSpec;
  16. if (!class_exists('\Eccube\Entity\Product')) {
  17.     /**
  18.      * Product
  19.      *
  20.      * @ORM\Table(name="dtb_product")
  21.      * @ORM\InheritanceType("SINGLE_TABLE")
  22.      * @ORM\DiscriminatorColumn(name="discriminator_type", type="string", length=255)
  23.      * @ORM\HasLifecycleCallbacks()
  24.      * @ORM\Entity(repositoryClass="Eccube\Repository\ProductRepository")
  25.      */
  26.     class Product extends \Eccube\Entity\AbstractEntity
  27.     {
  28.         private $_calc false;
  29.         private $stockFinds = [];
  30.         private $stocks = [];
  31.         private $stockUnlimiteds = [];
  32.         private $price01 = [];
  33.         private $price02 = [];
  34.         private $price01IncTaxs = [];
  35.         private $price02IncTaxs = [];
  36.         private $codes = [];
  37.         private $classCategories1 = [];
  38.         private $classCategories2 = [];
  39.         private $className1;
  40.         private $className2;
  41.         /**
  42.          * @var integer
  43.          *
  44.          * @ORM\Column(name="id", type="integer", options={"unsigned":true})
  45.          * @ORM\Id
  46.          * @ORM\GeneratedValue(strategy="IDENTITY")
  47.          */
  48.         private $id;
  49.         /**
  50.          * @var string
  51.          *
  52.          * @ORM\Column(name="name", type="string", length=255)
  53.          */
  54.         private $name;
  55.         /**
  56.          * @var string|null
  57.          *
  58.          * @ORM\Column(name="note", type="text", nullable=true)
  59.          */
  60.         private $note;
  61.         /**
  62.          * @var string|null
  63.          *
  64.          * @ORM\Column(name="description_list", type="text", nullable=true)
  65.          */
  66.         private $description_list;
  67.         /**
  68.          * @var string|null
  69.          *
  70.          * @ORM\Column(name="description_detail", type="text", nullable=true)
  71.          */
  72.         private $description_detail;
  73.         /**
  74.          * @var string|null
  75.          *
  76.          * @ORM\Column(name="search_word", type="text", nullable=true)
  77.          */
  78.         private $search_word;
  79.         /**
  80.          * @var string|null
  81.          *
  82.          * @ORM\Column(name="free_area", type="text", nullable=true)
  83.          */
  84.         private $free_area;
  85.         /**
  86.          * @var \DateTime
  87.          *
  88.          * @ORM\Column(name="create_date", type="datetimetz")
  89.          */
  90.         private $create_date;
  91.         /**
  92.          * @var \DateTime
  93.          *
  94.          * @ORM\Column(name="update_date", type="datetimetz")
  95.          */
  96.         private $update_date;
  97.         /**
  98.          * @var \Doctrine\Common\Collections\Collection
  99.          *
  100.          * @ORM\OneToMany(targetEntity="Eccube\Entity\ProductCategory", mappedBy="Product", cascade={"persist","remove"})
  101.          */
  102.         private $ProductCategories;
  103.         /**
  104.          * @var \Doctrine\Common\Collections\Collection
  105.          *
  106.          * @ORM\OneToMany(targetEntity="Eccube\Entity\ProductClass", mappedBy="Product", cascade={"persist","remove"})
  107.          */
  108.         private $ProductClasses;
  109.         /**
  110.          * @var \Doctrine\Common\Collections\Collection
  111.          *
  112.          * @ORM\OneToMany(targetEntity="Eccube\Entity\ProductImage", mappedBy="Product", cascade={"remove"})
  113.          * @ORM\OrderBy({
  114.          *     "sort_no"="ASC"
  115.          * })
  116.          */
  117.         private $ProductImage;
  118.         /**
  119.          * @var \Doctrine\Common\Collections\Collection
  120.          *
  121.          * @ORM\OneToMany(targetEntity="Eccube\Entity\ProductMakerSpec", mappedBy="Product", cascade={"persist", "remove"}, fetch="EAGER")
  122.          * @ORM\OrderBy({
  123.          *     "sort_no"="ASC"
  124.          * })
  125.          */
  126.         private $ProductMakerSpec;
  127.         /**
  128.          * @var \Doctrine\Common\Collections\Collection
  129.          *
  130.          * @ORM\OneToMany(targetEntity="Eccube\Entity\ProductTag", mappedBy="Product", cascade={"remove"})
  131.          */
  132.         private $ProductTag;
  133.         private $CustomerFavoriteProducts;
  134.         /**
  135.          * @var \Eccube\Entity\Member
  136.          *
  137.          * @ORM\ManyToOne(targetEntity="Eccube\Entity\Member")
  138.          * @ORM\JoinColumns({
  139.          *   @ORM\JoinColumn(name="creator_id", referencedColumnName="id")
  140.          * })
  141.          */
  142.         private $Creator;
  143.         /**
  144.          * @var \Eccube\Entity\Master\ProductStatus
  145.          *
  146.          * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\ProductStatus")
  147.          * @ORM\JoinColumns({
  148.          *   @ORM\JoinColumn(name="product_status_id", referencedColumnName="id")
  149.          * })
  150.          */
  151.         private $Status;
  152.         /**
  153.          * @return string
  154.          */
  155.         public function __toString()
  156.         {
  157.             return (string) $this->getName();
  158.         }
  159.         public function _calc()
  160.         {
  161.             if (!$this->_calc) {
  162.                 $i 0;
  163.                 foreach ($this->getProductClasses() as $ProductClass) {
  164.                     /* @var $ProductClass \Eccube\Entity\ProductClass */
  165.                     // stock_find
  166.                     if ($ProductClass->isVisible() == false) {
  167.                         continue;
  168.                     }
  169.                     $ClassCategory1 $ProductClass->getClassCategory1();
  170.                     $ClassCategory2 $ProductClass->getClassCategory2();
  171.                     if ($ClassCategory1 && !$ClassCategory1->isVisible()) {
  172.                         continue;
  173.                     }
  174.                     if ($ClassCategory2 && !$ClassCategory2->isVisible()) {
  175.                         continue;
  176.                     }
  177.                     // stock_find
  178.                     $this->stockFinds[] = $ProductClass->getStockFind();
  179.                     // stock
  180.                     $this->stocks[] = $ProductClass->getStock();
  181.                     // stock_unlimited
  182.                     $this->stockUnlimiteds[] = $ProductClass->isStockUnlimited();
  183.                     // price01
  184.                     if (!is_null($ProductClass->getPrice01())) {
  185.                         $this->price01[] = $ProductClass->getPrice01();
  186.                         // price01IncTax
  187.                         $this->price01IncTaxs[] = $ProductClass->getPrice01IncTax();
  188.                     }
  189.                     // price02
  190.                     $this->price02[] = $ProductClass->getPrice02();
  191.                     // price02IncTax
  192.                     $this->price02IncTaxs[] = $ProductClass->getPrice02IncTax();
  193.                     // product_code
  194.                     $this->codes[] = $ProductClass->getCode();
  195.                     if ($i === 0) {
  196.                         if ($ProductClass->getClassCategory1() && $ProductClass->getClassCategory1()->getId()) {
  197.                             $this->className1 $ProductClass->getClassCategory1()->getClassName()->getName();
  198.                         }
  199.                         if ($ProductClass->getClassCategory2() && $ProductClass->getClassCategory2()->getId()) {
  200.                             $this->className2 $ProductClass->getClassCategory2()->getClassName()->getName();
  201.                         }
  202.                     }
  203.                     if ($ProductClass->getClassCategory1()) {
  204.                         $classCategoryId1 $ProductClass->getClassCategory1()->getId();
  205.                         if (!empty($classCategoryId1)) {
  206.                             if ($ProductClass->getClassCategory2()) {
  207.                                 $this->classCategories1[$ProductClass->getClassCategory1()->getId()] = $ProductClass->getClassCategory1()->getName();
  208.                                 $this->classCategories2[$ProductClass->getClassCategory1()->getId()][$ProductClass->getClassCategory2()->getId()] = $ProductClass->getClassCategory2()->getName();
  209.                             } else {
  210.                                 $this->classCategories1[$ProductClass->getClassCategory1()->getId()] = $ProductClass->getClassCategory1()->getName().($ProductClass->getStockFind() ? '' trans('front.product.out_of_stock_label'));
  211.                             }
  212.                         }
  213.                     }
  214.                     $i++;
  215.                 }
  216.                 $this->_calc true;
  217.             }
  218.         }
  219.         /**
  220.          * Is Enable
  221.          *
  222.          * @return bool
  223.          *
  224.          * @deprecated
  225.          */
  226.         public function isEnable()
  227.         {
  228.             return $this->getStatus()->getId() === \Eccube\Entity\Master\ProductStatus::DISPLAY_SHOW true false;
  229.         }
  230.         /**
  231.          * Get ClassName1
  232.          *
  233.          * @return string
  234.          */
  235.         public function getClassName1()
  236.         {
  237.             $this->_calc();
  238.             return $this->className1;
  239.         }
  240.         /**
  241.          * Get ClassName2
  242.          *
  243.          * @return string
  244.          */
  245.         public function getClassName2()
  246.         {
  247.             $this->_calc();
  248.             return $this->className2;
  249.         }
  250.         /**
  251.          * Get getClassCategories1
  252.          *
  253.          * @return array
  254.          */
  255.         public function getClassCategories1()
  256.         {
  257.             $this->_calc();
  258.             return $this->classCategories1;
  259.         }
  260.         public function getClassCategories1AsFlip()
  261.         {
  262.             return array_flip($this->getClassCategories1());
  263.         }
  264.         /**
  265.          * Get getClassCategories2
  266.          *
  267.          * @return array
  268.          */
  269.         public function getClassCategories2($class_category1)
  270.         {
  271.             $this->_calc();
  272.             return isset($this->classCategories2[$class_category1]) ? $this->classCategories2[$class_category1] : [];
  273.         }
  274.         public function getClassCategories2AsFlip($class_category1)
  275.         {
  276.             return array_flip($this->getClassCategories2($class_category1));
  277.         }
  278.         /**
  279.          * Get StockFind
  280.          *
  281.          * @return bool
  282.          */
  283.         public function getStockFind()
  284.         {
  285.             $this->_calc();
  286.             return count($this->stockFinds)
  287.                 ? max($this->stockFinds)
  288.                 : null;
  289.         }
  290.         /**
  291.          * Get Stock min
  292.          *
  293.          * @return integer
  294.          */
  295.         public function getStockMin()
  296.         {
  297.             $this->_calc();
  298.             return count($this->stocks)
  299.                 ? min($this->stocks)
  300.                 : null;
  301.         }
  302.         /**
  303.          * Get Stock max
  304.          *
  305.          * @return integer
  306.          */
  307.         public function getStockMax()
  308.         {
  309.             $this->_calc();
  310.             return count($this->stocks)
  311.                 ? max($this->stocks)
  312.                 : null;
  313.         }
  314.         /**
  315.          * Get StockUnlimited min
  316.          *
  317.          * @return integer
  318.          */
  319.         public function getStockUnlimitedMin()
  320.         {
  321.             $this->_calc();
  322.             return count($this->stockUnlimiteds)
  323.                 ? min($this->stockUnlimiteds)
  324.                 : null;
  325.         }
  326.         /**
  327.          * Get StockUnlimited max
  328.          *
  329.          * @return integer
  330.          */
  331.         public function getStockUnlimitedMax()
  332.         {
  333.             $this->_calc();
  334.             return count($this->stockUnlimiteds)
  335.                 ? max($this->stockUnlimiteds)
  336.                 : null;
  337.         }
  338.         /**
  339.          * Get Price01 min
  340.          *
  341.          * @return integer
  342.          */
  343.         public function getPrice01Min()
  344.         {
  345.             $this->_calc();
  346.             if (count($this->price01) == 0) {
  347.                 return null;
  348.             }
  349.             return min($this->price01);
  350.         }
  351.         /**
  352.          * Get Price01 max
  353.          *
  354.          * @return integer
  355.          */
  356.         public function getPrice01Max()
  357.         {
  358.             $this->_calc();
  359.             if (count($this->price01) == 0) {
  360.                 return null;
  361.             }
  362.             return max($this->price01);
  363.         }
  364.         /**
  365.          * Get Price02 min
  366.          *
  367.          * @return integer
  368.          */
  369.         public function getPrice02Min()
  370.         {
  371.             $this->_calc();
  372.             return count($this->price02)
  373.                 ? min($this->price02)
  374.                 : null;
  375.         }
  376.         /**
  377.          * Get Price02 max
  378.          *
  379.          * @return integer
  380.          */
  381.         public function getPrice02Max()
  382.         {
  383.             $this->_calc();
  384.             return count($this->price02)
  385.                 ? max($this->price02)
  386.                 : null;
  387.         }
  388.         /**
  389.          * Get Price01IncTax min
  390.          *
  391.          * @return integer
  392.          */
  393.         public function getPrice01IncTaxMin()
  394.         {
  395.             $this->_calc();
  396.             return count($this->price01IncTaxs)
  397.                 ? min($this->price01IncTaxs)
  398.                 : null;
  399.         }
  400.         /**
  401.          * Get Price01IncTax max
  402.          *
  403.          * @return integer
  404.          */
  405.         public function getPrice01IncTaxMax()
  406.         {
  407.             $this->_calc();
  408.             return count($this->price01IncTaxs)
  409.                 ? max($this->price01IncTaxs)
  410.                 : null;
  411.         }
  412.         /**
  413.          * Get Price02IncTax min
  414.          *
  415.          * @return integer
  416.          */
  417.         public function getPrice02IncTaxMin()
  418.         {
  419.             $this->_calc();
  420.             return count($this->price02IncTaxs)
  421.                 ? min($this->price02IncTaxs)
  422.                 : null;
  423.         }
  424.         /**
  425.          * Get Price02IncTax max
  426.          *
  427.          * @return integer
  428.          */
  429.         public function getPrice02IncTaxMax()
  430.         {
  431.             $this->_calc();
  432.             return count($this->price02IncTaxs)
  433.                 ? max($this->price02IncTaxs)
  434.                 : null;
  435.         }
  436.         /**
  437.          * Get Product_code min
  438.          *
  439.          * @return integer
  440.          */
  441.         public function getCodeMin()
  442.         {
  443.             $this->_calc();
  444.             $codes = [];
  445.             foreach ($this->codes as $code) {
  446.                 if (!is_null($code)) {
  447.                     $codes[] = $code;
  448.                 }
  449.             }
  450.             return count($codes) ? min($codes) : null;
  451.         }
  452.         /**
  453.          * Get Product_code max
  454.          *
  455.          * @return integer
  456.          */
  457.         public function getCodeMax()
  458.         {
  459.             $this->_calc();
  460.             $codes = [];
  461.             foreach ($this->codes as $code) {
  462.                 if (!is_null($code)) {
  463.                     $codes[] = $code;
  464.                 }
  465.             }
  466.             return count($codes) ? max($codes) : null;
  467.         }
  468.         public function getMainListImage()
  469.         {
  470.             $ProductImages $this->getProductImage();
  471.             return $ProductImages->isEmpty() ? null $ProductImages[0];
  472.         }
  473.         public function getMainFileName()
  474.         {
  475.             if (count($this->ProductImage) > 0) {
  476.                 return $this->ProductImage[0];
  477.             } else {
  478.                 return null;
  479.             }
  480.         }
  481.         public function hasProductClass()
  482.         {
  483.             foreach ($this->ProductClasses as $ProductClass) {
  484.                 if (!$ProductClass->isVisible()) {
  485.                     continue;
  486.                 }
  487.                 if (!is_null($ProductClass->getClassCategory1())) {
  488.                     return true;
  489.                 }
  490.             }
  491.             return false;
  492.         }
  493.         /**
  494.          * Constructor
  495.          */
  496.         public function __construct()
  497.         {
  498.             $this->ProductCategories = new ArrayCollection();
  499.             $this->ProductClasses = new ArrayCollection();
  500.             $this->ProductImage = new ArrayCollection();
  501.             $this->ProductMakerSpec = new ArrayCollection();
  502.             $this->ProductTag = new ArrayCollection();
  503.             $this->CustomerFavoriteProducts = new ArrayCollection();
  504.         }
  505.         public function __clone()
  506.         {
  507.             $this->id null;
  508.         }
  509.         public function copy()
  510.         {
  511.             // コピー対象外
  512.             $this->CustomerFavoriteProducts = new ArrayCollection();
  513.             $Categories $this->getProductCategories();
  514.             $this->ProductCategories = new ArrayCollection();
  515.             foreach ($Categories as $Category) {
  516.                 $CopyCategory = clone $Category;
  517.                 $this->addProductCategory($CopyCategory);
  518.                 $CopyCategory->setProduct($this);
  519.             }
  520.             $Classes $this->getProductClasses();
  521.             $this->ProductClasses = new ArrayCollection();
  522.             foreach ($Classes as $Class) {
  523.                 $CopyClass = clone $Class;
  524.                 $this->addProductClass($CopyClass);
  525.                 $CopyClass->setProduct($this);
  526.             }
  527.             $Images $this->getProductImage();
  528.             $this->ProductImage = new ArrayCollection();
  529.             foreach ($Images as $Image) {
  530.                 $CloneImage = clone $Image;
  531.                 $this->addProductImage($CloneImage);
  532.                 $CloneImage->setProduct($this);
  533.             }
  534.             $MakerSpecs $this->getProductMakerSpec();
  535.             $this->ProductMakerSpec = new ArrayCollection();
  536.             foreach ($MakerSpecs as $spec) {
  537.                 $CloneSpec = clone $spec;
  538.                 $this->addProductMakerSpec($CloneSpec);
  539.                 $CloneSpec->setProduct($this);
  540.             }
  541.             $Tags $this->getProductTag();
  542.             $this->ProductTag = new ArrayCollection();
  543.             foreach ($Tags as $Tag) {
  544.                 $CloneTag = clone $Tag;
  545.                 $this->addProductTag($CloneTag);
  546.                 $CloneTag->setProduct($this);
  547.             }
  548.             return $this;
  549.         }
  550.         /**
  551.          * Set id.
  552.          *
  553.          */
  554.         public function setId(int $id) :self
  555.         {
  556.             $this->id $id;
  557.             return $this;
  558.         }
  559.         /**
  560.          * Get id.
  561.          *
  562.          * @return int
  563.          */
  564.         public function getId()
  565.         {
  566.             return $this->id;
  567.         }
  568.         /**
  569.          * Set name.
  570.          *
  571.          * @param string $name
  572.          *
  573.          * @return Product
  574.          */
  575.         public function setName($name)
  576.         {
  577.             $this->name $name;
  578.             return $this;
  579.         }
  580.         /**
  581.          * Get name.
  582.          *
  583.          * @return string
  584.          */
  585.         public function getName()
  586.         {
  587.             return $this->name;
  588.         }
  589.         /**
  590.          * Set note.
  591.          *
  592.          * @param string|null $note
  593.          *
  594.          * @return Product
  595.          */
  596.         public function setNote($note null)
  597.         {
  598.             $this->note $note;
  599.             return $this;
  600.         }
  601.         /**
  602.          * Get note.
  603.          *
  604.          * @return string|null
  605.          */
  606.         public function getNote()
  607.         {
  608.             return $this->note;
  609.         }
  610.         /**
  611.          * Set descriptionList.
  612.          *
  613.          * @param string|null $descriptionList
  614.          *
  615.          * @return Product
  616.          */
  617.         public function setDescriptionList($descriptionList null)
  618.         {
  619.             $this->description_list $descriptionList;
  620.             return $this;
  621.         }
  622.         /**
  623.          * Get descriptionList.
  624.          *
  625.          * @return string|null
  626.          */
  627.         public function getDescriptionList()
  628.         {
  629.             return $this->description_list;
  630.         }
  631.         /**
  632.          * Set descriptionDetail.
  633.          *
  634.          * @param string|null $descriptionDetail
  635.          *
  636.          * @return Product
  637.          */
  638.         public function setDescriptionDetail($descriptionDetail null)
  639.         {
  640.             $this->description_detail $descriptionDetail;
  641.             return $this;
  642.         }
  643.         /**
  644.          * Get descriptionDetail.
  645.          *
  646.          * @return string|null
  647.          */
  648.         public function getDescriptionDetail()
  649.         {
  650.             $descriptionDetail $this->description_detail;
  651.             return $descriptionDetail;
  652.         }
  653.         /**
  654.          * Set searchWord.
  655.          *
  656.          * @param string|null $searchWord
  657.          *
  658.          * @return Product
  659.          */
  660.         public function setSearchWord($searchWord null)
  661.         {
  662.             $this->search_word $searchWord;
  663.             return $this;
  664.         }
  665.         /**
  666.          * Get searchWord.
  667.          *
  668.          * @return string|null
  669.          */
  670.         public function getSearchWord()
  671.         {
  672.             return $this->search_word;
  673.         }
  674.         /**
  675.          * Set freeArea.
  676.          *
  677.          * @param string|null $freeArea
  678.          *
  679.          * @return Product
  680.          */
  681.         public function setFreeArea($freeArea null)
  682.         {
  683.             $this->free_area $freeArea;
  684.             return $this;
  685.         }
  686.         /**
  687.          * Get freeArea.
  688.          *
  689.          * @return string|null
  690.          */
  691.         public function getFreeArea()
  692.         {
  693.             return $this->free_area;
  694.         }
  695.         /**
  696.          * Set createDate.
  697.          *
  698.          * @param \DateTime $createDate
  699.          *
  700.          * @return Product
  701.          */
  702.         public function setCreateDate($createDate)
  703.         {
  704.             $this->create_date $createDate;
  705.             return $this;
  706.         }
  707.         /**
  708.          * Get createDate.
  709.          *
  710.          * @return \DateTime
  711.          */
  712.         public function getCreateDate()
  713.         {
  714.             return $this->create_date;
  715.         }
  716.         /**
  717.          * Set updateDate.
  718.          *
  719.          * @param \DateTime $updateDate
  720.          *
  721.          * @return Product
  722.          */
  723.         public function setUpdateDate($updateDate)
  724.         {
  725.             $this->update_date $updateDate;
  726.             return $this;
  727.         }
  728.         /**
  729.          * Get updateDate.
  730.          *
  731.          * @return \DateTime
  732.          */
  733.         public function getUpdateDate()
  734.         {
  735.             return $this->update_date;
  736.         }
  737.         /**
  738.          * Add productCategory.
  739.          *
  740.          * @param \Eccube\Entity\ProductCategory $productCategory
  741.          *
  742.          * @return Product
  743.          */
  744.         public function addProductCategory(ProductCategory $productCategory)
  745.         {
  746.             $this->ProductCategories[] = $productCategory;
  747.             return $this;
  748.         }
  749.         /**
  750.          * Remove productCategory.
  751.          *
  752.          * @param \Eccube\Entity\ProductCategory $productCategory
  753.          *
  754.          * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
  755.          */
  756.         public function removeProductCategory(ProductCategory $productCategory)
  757.         {
  758.             return $this->ProductCategories->removeElement($productCategory);
  759.         }
  760.         /**
  761.          * Get productCategories.
  762.          *
  763.          * @return \Doctrine\Common\Collections\Collection
  764.          */
  765.         public function getProductCategories()
  766.         {
  767.             return $this->ProductCategories;
  768.         }
  769.         /**
  770.          * Add productClass.
  771.          *
  772.          * @param \Eccube\Entity\ProductClass $productClass
  773.          *
  774.          * @return Product
  775.          */
  776.         public function addProductClass(ProductClass $productClass)
  777.         {
  778.             $this->ProductClasses[] = $productClass;
  779.             return $this;
  780.         }
  781.         /**
  782.          * Remove productClass.
  783.          *
  784.          * @param \Eccube\Entity\ProductClass $productClass
  785.          *
  786.          * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
  787.          */
  788.         public function removeProductClass(ProductClass $productClass)
  789.         {
  790.             return $this->ProductClasses->removeElement($productClass);
  791.         }
  792.         /**
  793.          * Get productClasses.
  794.          *
  795.          * @return \Doctrine\Common\Collections\Collection
  796.          */
  797.         public function getProductClasses()
  798.         {
  799.             return $this->ProductClasses;
  800.         }
  801.         /**
  802.          * Add productImage.
  803.          *
  804.          * @param \Eccube\Entity\ProductImage $productImage
  805.          *
  806.          * @return Product
  807.          */
  808.         public function addProductImage(ProductImage $productImage)
  809.         {
  810.             $this->ProductImage[] = $productImage;
  811.             return $this;
  812.         }
  813.         /**
  814.          * Remove productImage.
  815.          *
  816.          * @param \Eccube\Entity\ProductImage $productImage
  817.          *
  818.          * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
  819.          */
  820.         public function removeProductImage(ProductImage $productImage)
  821.         {
  822.             return $this->ProductImage->removeElement($productImage);
  823.         }
  824.         /**
  825.          * Get productImage.
  826.          *
  827.          * @return \Doctrine\Common\Collections\Collection
  828.          */
  829.         public function getProductImage()
  830.         {
  831.             return $this->ProductImage;
  832.         }
  833.         /**
  834.          * Get productMakerSpec.
  835.          *
  836.          * @return \Doctrine\Common\Collections\Collection
  837.          */
  838.         public function getProductMakerSpecs()
  839.         {
  840.             return $this->ProductMakerSpec;
  841.         }
  842.         /**
  843.          * Add productMakerSpec.
  844.          *
  845.          * @param \Eccube\Entity\ProductMakerSpec $productMakerSpec
  846.          *
  847.          * @return Product
  848.          */
  849.         public function addProductMakerSpec(ProductMakerSpec $productMakerSpec): self
  850.         {
  851.             $this->ProductMakerSpec[] = $productMakerSpec;
  852.             return $this;
  853.         }
  854.         /**
  855.          * Remove productMakerSpec.
  856.          *
  857.          * @param \Eccube\Entity\ProductMakerSpec $productMakerSpec
  858.          *
  859.          * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
  860.          */
  861.         public function removeProductMakerSpec(ProductMakerSpec $productMakerSpec): bool
  862.         {
  863.             $removed $this->ProductMakerSpec->removeElement($productMakerSpec);
  864.             if ($removed) {
  865.                 // 関連を切るが、必要な場合にのみ null を設定
  866.                 if ($productMakerSpec->getProduct() === $this) {
  867.                     $productMakerSpec->setProduct(null);
  868.                 }
  869.             }
  870.             return $removed;
  871.         }
  872.         /**
  873.          * Clear all ProductMakerSpec entities from the collection.
  874.          *
  875.          * @return self
  876.          */
  877.         public function clearProductMakerSpec(): self
  878.         {
  879.             foreach ($this->ProductMakerSpec as $productMakerSpec) {
  880.                 $this->removeProductMakerSpec($productMakerSpec);
  881.             }
  882.             return $this;
  883.         }
  884.         /**
  885.          * Add productTag.
  886.          *
  887.          * @param \Eccube\Entity\ProductTag $productTag
  888.          *
  889.          * @return Product
  890.          */
  891.         public function addProductTag(ProductTag $productTag)
  892.         {
  893.             $this->ProductTag[] = $productTag;
  894.             return $this;
  895.         }
  896.         /**
  897.          * Remove productTag.
  898.          *
  899.          * @param \Eccube\Entity\ProductTag $productTag
  900.          *
  901.          * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
  902.          */
  903.         public function removeProductTag(ProductTag $productTag)
  904.         {
  905.             return $this->ProductTag->removeElement($productTag);
  906.         }
  907.         /**
  908.          * Get productTag.
  909.          *
  910.          * @return \Doctrine\Common\Collections\Collection
  911.          */
  912.         public function getProductTag()
  913.         {
  914.             return $this->ProductTag;
  915.         }
  916.         /**
  917.          * Get Tag
  918.          * フロント側タグsort_no順の配列を作成する
  919.          *
  920.          * @return []Tag
  921.          */
  922.         public function getTags()
  923.         {
  924.             $tags = [];
  925.             foreach ($this->getProductTag() as $productTag) {
  926.                 $tags[] = $productTag->getTag();
  927.             }
  928.             usort($tags, function (Tag $tag1Tag $tag2) {
  929.                 return $tag1->getSortNo() < $tag2->getSortNo();
  930.             });
  931.             return $tags;
  932.         }
  933.         /**
  934.          * Add customerFavoriteProduct.
  935.          *
  936.          * @param \Eccube\Entity\CustomerFavoriteProduct $customerFavoriteProduct
  937.          *
  938.          * @return Product
  939.          */
  940.         public function addCustomerFavoriteProduct(CustomerFavoriteProduct $customerFavoriteProduct)
  941.         {
  942.             $this->CustomerFavoriteProducts[] = $customerFavoriteProduct;
  943.             return $this;
  944.         }
  945.         /**
  946.          * Remove customerFavoriteProduct.
  947.          *
  948.          * @param \Eccube\Entity\CustomerFavoriteProduct $customerFavoriteProduct
  949.          *
  950.          * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
  951.          */
  952.         public function removeCustomerFavoriteProduct(CustomerFavoriteProduct $customerFavoriteProduct)
  953.         {
  954.             return $this->CustomerFavoriteProducts->removeElement($customerFavoriteProduct);
  955.         }
  956.         /**
  957.          * Get customerFavoriteProducts.
  958.          *
  959.          * @return \Doctrine\Common\Collections\Collection
  960.          */
  961.         public function getCustomerFavoriteProducts()
  962.         {
  963.             return $this->CustomerFavoriteProducts;
  964.         }
  965.         /**
  966.          * Set creator.
  967.          *
  968.          * @param \Eccube\Entity\Member|null $creator
  969.          *
  970.          * @return Product
  971.          */
  972.         public function setCreator(Member $creator null)
  973.         {
  974.             $this->Creator $creator;
  975.             return $this;
  976.         }
  977.         /**
  978.          * Get creator.
  979.          *
  980.          * @return \Eccube\Entity\Member|null
  981.          */
  982.         public function getCreator()
  983.         {
  984.             return $this->Creator;
  985.         }
  986.         /**
  987.          * Set status.
  988.          *
  989.          * @param \Eccube\Entity\Master\ProductStatus|null $status
  990.          *
  991.          * @return Product
  992.          */
  993.         public function setStatus(Master\ProductStatus $status null)
  994.         {
  995.             $this->Status $status;
  996.             return $this;
  997.         }
  998.         /**
  999.          * Get status.
  1000.          *
  1001.          * @return \Eccube\Entity\Master\ProductStatus|null
  1002.          */
  1003.         public function getStatus()
  1004.         {
  1005.             return $this->Status;
  1006.         }
  1007.         /**
  1008.          * Get status.
  1009.          *
  1010.          * @return \Doctrine\Common\Collections\Collection
  1011.          */
  1012.         public function getProductMakerSpec()
  1013.         {
  1014.             return $this->ProductMakerSpec;
  1015.         }
  1016.     }
  1017. }