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