app/proxy/entity/src/Eccube/Entity/Product.php line 29

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