Failed Conditions
Pull Request — 4.0 (#3537)
by k-yamamura
06:56
created

Product::isEnable()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 4
ccs 1
cts 1
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) LOCKON CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.lockon.co.jp/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Eccube\Entity;
15
16
use Doctrine\Common\Collections\ArrayCollection;
17
use Doctrine\ORM\Mapping as ORM;
18
19 1
if (!class_exists('\Eccube\Entity\Product')) {
20
    /**
21
     * Product
22
     *
23
     * @ORM\Table(name="dtb_product")
24
     * @ORM\InheritanceType("SINGLE_TABLE")
25
     * @ORM\DiscriminatorColumn(name="discriminator_type", type="string", length=255)
26
     * @ORM\HasLifecycleCallbacks()
27
     * @ORM\Entity(repositoryClass="Eccube\Repository\ProductRepository")
28
     */
29
    class Product extends \Eccube\Entity\AbstractEntity
30
    {
31
        private $_calc = false;
32
        private $stockFinds = [];
33
        private $stocks = [];
34
        private $stockUnlimiteds = [];
35
        private $price01 = [];
36
        private $price02 = [];
37
        private $price01IncTaxs = [];
38
        private $price02IncTaxs = [];
39
        private $codes = [];
40
        private $classCategories1 = [];
41
        private $classCategories2 = [];
42
        private $className1;
43
        private $className2;
44
45
        /**
46
         * @return string
47
         */
48
        public function __toString()
49
        {
50
            return (string) $this->getName();
51
        }
52
53 49
        public function _calc()
54
        {
55 49
            if (!$this->_calc) {
56 49
                $i = 0;
57 49
                foreach ($this->getProductClasses() as $ProductClass) {
58
                    /* @var $ProductClass \Eccube\Entity\ProductClass */
59
                    // stock_find
60 49
                    if ($ProductClass->isVisible() == false) {
61 49
                        continue;
62
                    }
63 49
                    $ClassCategory1 = $ProductClass->getClassCategory1();
64 49
                    $ClassCategory2 = $ProductClass->getClassCategory2();
65 49
                    if ($ClassCategory1 && !$ClassCategory1->isVisible()) {
66
                        continue;
67
                    }
68 49
                    if ($ClassCategory2 && !$ClassCategory2->isVisible()) {
69
                        continue;
70
                    }
71
72
                    // stock_find
73 49
                    $this->stockFinds[] = $ProductClass->getStockFind();
74
75
                    // stock
76 49
                    $this->stocks[] = $ProductClass->getStock();
77
78
                    // stock_unlimited
79 49
                    $this->stockUnlimiteds[] = $ProductClass->isStockUnlimited();
80
81
                    // price01
82 49
                    if (!is_null($ProductClass->getPrice01())) {
83 7
                        $this->price01[] = $ProductClass->getPrice01();
84
                        // price01IncTax
85 7
                        $this->price01IncTaxs[] = $ProductClass->getPrice01IncTax();
86
                    }
87
88
                    // price02
89 49
                    $this->price02[] = $ProductClass->getPrice02();
90
91
                    // price02IncTax
92 49
                    $this->price02IncTaxs[] = $ProductClass->getPrice02IncTax();
93
94
                    // product_code
95 49
                    $this->codes[] = $ProductClass->getCode();
96
97 49
                    if ($i === 0) {
98 49
                        if ($ProductClass->getClassCategory1() && $ProductClass->getClassCategory1()->getId()) {
99 49
                            $this->className1 = $ProductClass->getClassCategory1()->getClassName()->getName();
100
                        }
101 49
                        if ($ProductClass->getClassCategory2() && $ProductClass->getClassCategory2()->getId()) {
102 33
                            $this->className2 = $ProductClass->getClassCategory2()->getClassName()->getName();
103
                        }
104
                    }
105 49
                    if ($ProductClass->getClassCategory1()) {
106 49
                        $classCategoryId1 = $ProductClass->getClassCategory1()->getId();
107 49
                        if (!empty($classCategoryId1)) {
108 49
                            if ($ProductClass->getClassCategory2()) {
109 49
                                $this->classCategories1[$ProductClass->getClassCategory1()->getId()] = $ProductClass->getClassCategory1()->getName();
110 33
                                $this->classCategories2[$ProductClass->getClassCategory1()->getId()][$ProductClass->getClassCategory2()->getId()] = $ProductClass->getClassCategory2()->getName();
111
                            } else {
112
                                $this->classCategories1[$ProductClass->getClassCategory1()->getId()] = $ProductClass->getClassCategory1()->getName().($ProductClass->getStockFind() ? '' : trans('product.text.out_of_stock'));
113
                            }
114 49
                        }
115
                    }
116 49
                    $i++;
117
                }
118
                $this->_calc = true;
119
            }
120
        }
121
122
        /**
123
         * Is Enable
124
         *
125 80
         * @return bool
126
         */
127 80
        public function isEnable()
128
        {
129
            return $this->getStatus()->getId() === \Eccube\Entity\Master\ProductStatus::DISPLAY_SHOW ? true : false;
130
        }
131
132
        /**
133
         * Get ClassName1
134
         *
135 45
         * @return string
136
         */
137 45
        public function getClassName1()
138
        {
139 45
            $this->_calc();
140
141
            return $this->className1;
142
        }
143
144
        /**
145
         * Get ClassName2
146
         *
147 45
         * @return string
148
         */
149 45
        public function getClassName2()
150
        {
151 45
            $this->_calc();
152
153
            return $this->className2;
154
        }
155
156
        /**
157
         * Get getClassCategories1
158
         *
159 46
         * @return array
160
         */
161 46
        public function getClassCategories1()
162
        {
163 46
            $this->_calc();
164
165
            return $this->classCategories1;
166 45
        }
167
168 45
        public function getClassCategories1AsFlip()
169
        {
170
            return array_flip($this->getClassCategories1());
171
        }
172
173
        /**
174
         * Get getClassCategories2
175
         *
176 4
         * @return array
177
         */
178 4
        public function getClassCategories2($class_category1)
179
        {
180 4
            $this->_calc();
181
182
            return isset($this->classCategories2[$class_category1]) ? $this->classCategories2[$class_category1] : [];
183 3
        }
184
185 3
        public function getClassCategories2AsFlip($class_category1)
186
        {
187
            return array_flip($this->getClassCategories2($class_category1));
188
        }
189
190
        /**
191
         * Get StockFind
192
         *
193 46
         * @return bool
194
         */
195 46
        public function getStockFind()
196
        {
197 46
            $this->_calc();
198
199
            return max($this->stockFinds);
200
        }
201
202
        /**
203
         * Get Stock min
204
         *
205
         * @return integer
206
         */
207
        public function getStockMin()
208
        {
209
            $this->_calc();
210
211
            return min($this->stocks);
212
        }
213
214
        /**
215
         * Get Stock max
216
         *
217
         * @return integer
218
         */
219
        public function getStockMax()
220
        {
221
            $this->_calc();
222
223
            return max($this->stocks);
224
        }
225
226
        /**
227
         * Get StockUnlimited min
228
         *
229
         * @return integer
230
         */
231
        public function getStockUnlimitedMin()
232
        {
233
            $this->_calc();
234
235
            return min($this->stockUnlimiteds);
236
        }
237
238
        /**
239
         * Get StockUnlimited max
240
         *
241
         * @return integer
242
         */
243
        public function getStockUnlimitedMax()
244
        {
245
            $this->_calc();
246
247
            return max($this->stockUnlimiteds);
248
        }
249
250
        /**
251
         * Get Price01 min
252
         *
253 11
         * @return integer
254
         */
255 11 View Code Duplication
        public function getPrice01Min()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
256
        {
257 11
            $this->_calc();
258 9
259
            if (count($this->price01) == 0) {
260
                return null;
261 2
            }
262
263
            return min($this->price01);
264
        }
265
266
        /**
267
         * Get Price01 max
268
         *
269 2
         * @return integer
270
         */
271 2 View Code Duplication
        public function getPrice01Max()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
272
        {
273 2
            $this->_calc();
274
275
            if (count($this->price01) == 0) {
276
                return null;
277 2
            }
278
279
            return max($this->price01);
280
        }
281
282
        /**
283
         * Get Price02 min
284
         *
285 3
         * @return integer
286
         */
287 3
        public function getPrice02Min()
288
        {
289 3
            $this->_calc();
290
291
            return min($this->price02);
292
        }
293
294
        /**
295
         * Get Price02 max
296
         *
297 3
         * @return integer
298
         */
299 3
        public function getPrice02Max()
300
        {
301 3
            $this->_calc();
302
303
            return max($this->price02);
304
        }
305
306
        /**
307
         * Get Price01IncTax min
308
         *
309 2
         * @return integer
310
         */
311 2
        public function getPrice01IncTaxMin()
312
        {
313 2
            $this->_calc();
314
315
            return min($this->price01IncTaxs);
316
        }
317
318
        /**
319
         * Get Price01IncTax max
320
         *
321 2
         * @return integer
322
         */
323 2
        public function getPrice01IncTaxMax()
324
        {
325 2
            $this->_calc();
326
327
            return max($this->price01IncTaxs);
328
        }
329
330
        /**
331
         * Get Price02IncTax min
332
         *
333 14
         * @return integer
334
         */
335 14
        public function getPrice02IncTaxMin()
336
        {
337 14
            $this->_calc();
338
339
            return min($this->price02IncTaxs);
340
        }
341
342
        /**
343
         * Get Price02IncTax max
344
         *
345 14
         * @return integer
346
         */
347 14
        public function getPrice02IncTaxMax()
348
        {
349 14
            $this->_calc();
350
351
            return max($this->price02IncTaxs);
352
        }
353
354
        /**
355
         * Get Product_code min
356
         *
357 13
         * @return integer
358
         */
359 13 View Code Duplication
        public function getCodeMin()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
360
        {
361 13
            $this->_calc();
362 13
363 13
            $codes = [];
364 13
            foreach ($this->codes as $code) {
365
                if (!is_null($code)) {
366
                    $codes[] = $code;
367
                }
368 13
            }
369
370
            return count($codes) ? min($codes) : null;
371
        }
372
373
        /**
374
         * Get Product_code max
375
         *
376 13
         * @return integer
377
         */
378 13 View Code Duplication
        public function getCodeMax()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
379
        {
380 13
            $this->_calc();
381 13
382 13
            $codes = [];
383 13
            foreach ($this->codes as $code) {
384
                if (!is_null($code)) {
385
                    $codes[] = $code;
386
                }
387 13
            }
388
389
            return count($codes) ? max($codes) : null;
390 62
        }
391
392 62
        public function getMainListImage()
393
        {
394 62
            $ProductImages = $this->getProductImage();
395
396
            return empty($ProductImages) ? null : $ProductImages[0];
397 1
        }
398
399 1
        public function getMainFileName()
400 1
        {
401
            if (count($this->ProductImage) > 0) {
402
                return $this->ProductImage[0];
403
            } else {
404
                return null;
405
            }
406 43
        }
407
408 43
        public function hasProductClass()
409 43
        {
410 1
            foreach ($this->ProductClasses as $ProductClass) {
411
                if (!$ProductClass->isVisible()) {
412 43
                    continue;
413 43
                }
414
                if (!is_null($ProductClass->getClassCategory1())) {
415
                    return true;
416
                }
417 18
            }
418
419
            return false;
420
        }
421
422
        /**
423
         * @var integer
424
         *
425
         * @ORM\Column(name="id", type="integer", options={"unsigned":true})
426
         * @ORM\Id
427
         * @ORM\GeneratedValue(strategy="IDENTITY")
428
         */
429
        private $id;
430
431
        /**
432
         * @var string
433
         *
434
         * @ORM\Column(name="name", type="string", length=255)
435
         */
436
        private $name;
437
438
        /**
439
         * @var string|null
440
         *
441
         * @ORM\Column(name="note", type="string", length=4000, nullable=true)
442
         */
443
        private $note;
444
445
        /**
446
         * @var string|null
447
         *
448
         * @ORM\Column(name="description_list", type="string", length=4000, nullable=true)
449
         */
450
        private $description_list;
451
452
        /**
453
         * @var string|null
454
         *
455
         * @ORM\Column(name="description_detail", type="string", length=4000, nullable=true)
456
         */
457
        private $description_detail;
458
459
        /**
460
         * @var string|null
461
         *
462
         * @ORM\Column(name="search_word", type="string", length=4000, nullable=true)
463
         */
464
        private $search_word;
465
466
        /**
467
         * @var string|null
468
         *
469
         * @ORM\Column(name="free_area", type="text", nullable=true)
470
         */
471
        private $free_area;
472
473
        /**
474
         * @var \DateTime
475
         *
476
         * @ORM\Column(name="create_date", type="datetimetz")
477
         */
478
        private $create_date;
479
480
        /**
481
         * @var \DateTime
482
         *
483
         * @ORM\Column(name="update_date", type="datetimetz")
484
         */
485
        private $update_date;
486
487
        /**
488
         * @var \Doctrine\Common\Collections\Collection
489
         *
490
         * @ORM\OneToMany(targetEntity="Eccube\Entity\ProductCategory", mappedBy="Product", cascade={"persist","remove"})
491
         */
492
        private $ProductCategories;
493
494
        /**
495
         * @var \Doctrine\Common\Collections\Collection
496
         *
497
         * @ORM\OneToMany(targetEntity="Eccube\Entity\ProductClass", mappedBy="Product", cascade={"persist","remove"})
498
         */
499
        private $ProductClasses;
500
501
        /**
502
         * @var \Doctrine\Common\Collections\Collection
503
         *
504
         * @ORM\OneToMany(targetEntity="Eccube\Entity\ProductImage", mappedBy="Product", cascade={"remove"})
505
         * @ORM\OrderBy({
506
         *     "sort_no"="ASC"
507
         * })
508
         */
509
        private $ProductImage;
510
511
        /**
512
         * @var \Doctrine\Common\Collections\Collection
513
         *
514
         * @ORM\OneToMany(targetEntity="Eccube\Entity\ProductTag", mappedBy="Product")
515
         */
516
        private $ProductTag;
517
518
        /**
519
         * @var \Doctrine\Common\Collections\Collection
520
         *
521
         * @ORM\OneToMany(targetEntity="Eccube\Entity\CustomerFavoriteProduct", mappedBy="Product")
522
         */
523
        private $CustomerFavoriteProducts;
524
525
        /**
526
         * @var \Eccube\Entity\Member
527
         *
528
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Member")
529
         * @ORM\JoinColumns({
530
         *   @ORM\JoinColumn(name="creator_id", referencedColumnName="id")
531
         * })
532
         */
533
        private $Creator;
534
535
        /**
536
         * @var \Eccube\Entity\Master\ProductStatus
537
         *
538
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\ProductStatus")
539
         * @ORM\JoinColumns({
540
         *   @ORM\JoinColumn(name="product_status_id", referencedColumnName="id")
541
         * })
542
         */
543
        private $Status;
544
545
        /**
546 409
         * Constructor
547
         */
548 409
        public function __construct()
549 409
        {
550 409
            $this->ProductCategories = new \Doctrine\Common\Collections\ArrayCollection();
551 409
            $this->ProductClasses = new \Doctrine\Common\Collections\ArrayCollection();
552 409
            $this->ProductImage = new \Doctrine\Common\Collections\ArrayCollection();
553
            $this->ProductTag = new \Doctrine\Common\Collections\ArrayCollection();
554
            $this->CustomerFavoriteProducts = new \Doctrine\Common\Collections\ArrayCollection();
555 1
        }
556
557 1
        public function __clone()
558
        {
559
            $this->id = null;
560 1
        }
561
562
        public function copy()
563 1
        {
564
            // コピー対象外
565 1
            $this->CustomerFavoriteProducts = new ArrayCollection();
566 1
567 1
            $Categories = $this->getProductCategories();
568 1
            $this->ProductCategories = new ArrayCollection();
569 1
            foreach ($Categories as $Category) {
570 1
                $CopyCategory = clone $Category;
571
                $this->addProductCategory($CopyCategory);
572
                $CopyCategory->setProduct($this);
573 1
            }
574 1
575 1
            $Classes = $this->getProductClasses();
576 1
            $this->ProductClasses = new ArrayCollection();
577 1
            foreach ($Classes as $Class) {
578 1
                $CopyClass = clone $Class;
579
                $this->addProductClass($CopyClass);
580
                $CopyClass->setProduct($this);
581 1
            }
582 1
583 1
            $Images = $this->getProductImage();
584 1
            $this->ProductImage = new ArrayCollection();
585 1
            foreach ($Images as $Image) {
586 1
                $CloneImage = clone $Image;
587
                $this->addProductImage($CloneImage);
588
                $CloneImage->setProduct($this);
589 1
            }
590 1
591 1
            $Tags = $this->getProductTag();
592
            $this->ProductTag = new ArrayCollection();
593
            foreach ($Tags as $Tag) {
594
                $CloneTag = clone $Tag;
595
                $this->addProductTag($CloneTag);
596
                $CloneTag->setProduct($this);
597 1
            }
598
599
            return $this;
600
        }
601
602
        /**
603
         * Get id.
604
         *
605 418
         * @return int
606
         */
607 418
        public function getId()
608
        {
609
            return $this->id;
610
        }
611
612
        /**
613
         * Set name.
614
         *
615
         * @param string $name
616
         *
617 409
         * @return Product
618
         */
619 409
        public function setName($name)
620
        {
621 409
            $this->name = $name;
622
623
            return $this;
624
        }
625
626
        /**
627
         * Get name.
628
         *
629 279
         * @return string
630
         */
631 279
        public function getName()
632
        {
633
            return $this->name;
634
        }
635
636
        /**
637
         * Set note.
638
         *
639
         * @param string|null $note
640
         *
641 25
         * @return Product
642
         */
643 25
        public function setNote($note = null)
644
        {
645 25
            $this->note = $note;
646
647
            return $this;
648
        }
649
650
        /**
651
         * Get note.
652
         *
653 18
         * @return string|null
654
         */
655 18
        public function getNote()
656
        {
657
            return $this->note;
658
        }
659
660
        /**
661
         * Set descriptionList.
662
         *
663
         * @param string|null $descriptionList
664
         *
665 406
         * @return Product
666
         */
667 406
        public function setDescriptionList($descriptionList = null)
668
        {
669 406
            $this->description_list = $descriptionList;
670
671
            return $this;
672
        }
673
674
        /**
675
         * Get descriptionList.
676
         *
677 20
         * @return string|null
678
         */
679 20
        public function getDescriptionList()
680
        {
681
            return $this->description_list;
682
        }
683
684
        /**
685
         * Set descriptionDetail.
686
         *
687
         * @param string|null $descriptionDetail
688
         *
689 406
         * @return Product
690
         */
691 406
        public function setDescriptionDetail($descriptionDetail = null)
692
        {
693 406
            $this->description_detail = $descriptionDetail;
694
695
            return $this;
696
        }
697
698
        /**
699
         * Get descriptionDetail.
700
         *
701 29
         * @return string|null
702
         */
703 29
        public function getDescriptionDetail()
704
        {
705
            return $this->description_detail;
706
        }
707
708
        /**
709
         * Set searchWord.
710
         *
711
         * @param string|null $searchWord
712
         *
713 23
         * @return Product
714
         */
715 23
        public function setSearchWord($searchWord = null)
716
        {
717 23
            $this->search_word = $searchWord;
718
719
            return $this;
720
        }
721
722
        /**
723
         * Get searchWord.
724
         *
725 18
         * @return string|null
726
         */
727 18
        public function getSearchWord()
728
        {
729
            return $this->search_word;
730
        }
731
732
        /**
733
         * Set freeArea.
734
         *
735
         * @param string|null $freeArea
736
         *
737 25
         * @return Product
738
         */
739 25
        public function setFreeArea($freeArea = null)
740
        {
741 25
            $this->free_area = $freeArea;
742
743
            return $this;
744
        }
745
746
        /**
747
         * Get freeArea.
748
         *
749 29
         * @return string|null
750
         */
751 29
        public function getFreeArea()
752
        {
753
            return $this->free_area;
754
        }
755
756
        /**
757
         * Set createDate.
758
         *
759
         * @param \DateTime $createDate
760
         *
761 408
         * @return Product
762
         */
763 408
        public function setCreateDate($createDate)
764
        {
765 408
            $this->create_date = $createDate;
766
767
            return $this;
768
        }
769
770
        /**
771
         * Get createDate.
772
         *
773 8
         * @return \DateTime
774
         */
775 8
        public function getCreateDate()
776
        {
777
            return $this->create_date;
778
        }
779
780
        /**
781
         * Set updateDate.
782
         *
783
         * @param \DateTime $updateDate
784
         *
785 409
         * @return Product
786
         */
787 409
        public function setUpdateDate($updateDate)
788
        {
789 409
            $this->update_date = $updateDate;
790
791
            return $this;
792
        }
793
794
        /**
795
         * Get updateDate.
796
         *
797 7
         * @return \DateTime
798
         */
799 7
        public function getUpdateDate()
800
        {
801
            return $this->update_date;
802
        }
803
804
        /**
805
         * Add productCategory.
806
         *
807
         * @param \Eccube\Entity\ProductCategory $productCategory
808
         *
809 398
         * @return Product
810
         */
811 398
        public function addProductCategory(\Eccube\Entity\ProductCategory $productCategory)
812
        {
813 398
            $this->ProductCategories[] = $productCategory;
814
815
            return $this;
816
        }
817
818
        /**
819
         * Remove productCategory.
820
         *
821
         * @param \Eccube\Entity\ProductCategory $productCategory
822
         *
823 12
         * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
824
         */
825 12
        public function removeProductCategory(\Eccube\Entity\ProductCategory $productCategory)
826
        {
827
            return $this->ProductCategories->removeElement($productCategory);
828
        }
829
830
        /**
831
         * Get productCategories.
832
         *
833 38
         * @return \Doctrine\Common\Collections\Collection
834
         */
835 38
        public function getProductCategories()
836
        {
837
            return $this->ProductCategories;
838
        }
839
840
        /**
841
         * Add productClass.
842
         *
843
         * @param \Eccube\Entity\ProductClass $productClass
844
         *
845 409
         * @return Product
846
         */
847 409
        public function addProductClass(\Eccube\Entity\ProductClass $productClass)
848
        {
849 409
            $this->ProductClasses[] = $productClass;
850
851
            return $this;
852
        }
853
854
        /**
855
         * Remove productClass.
856
         *
857
         * @param \Eccube\Entity\ProductClass $productClass
858
         *
859
         * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
860
         */
861
        public function removeProductClass(\Eccube\Entity\ProductClass $productClass)
862
        {
863
            return $this->ProductClasses->removeElement($productClass);
864
        }
865
866
        /**
867
         * Get productClasses.
868
         *
869 375
         * @return \Doctrine\Common\Collections\Collection
870
         */
871 375
        public function getProductClasses()
872
        {
873
            return $this->ProductClasses;
874
        }
875
876
        /**
877
         * Add productImage.
878
         *
879
         * @param \Eccube\Entity\ProductImage $productImage
880
         *
881 398
         * @return Product
882
         */
883 398
        public function addProductImage(\Eccube\Entity\ProductImage $productImage)
884
        {
885 398
            $this->ProductImage[] = $productImage;
886
887
            return $this;
888
        }
889
890
        /**
891
         * Remove productImage.
892
         *
893
         * @param \Eccube\Entity\ProductImage $productImage
894
         *
895 2
         * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
896
         */
897 2
        public function removeProductImage(\Eccube\Entity\ProductImage $productImage)
898
        {
899
            return $this->ProductImage->removeElement($productImage);
900
        }
901
902
        /**
903
         * Get productImage.
904
         *
905 95
         * @return \Doctrine\Common\Collections\Collection
906
         */
907 95
        public function getProductImage()
908
        {
909
            return $this->ProductImage;
910
        }
911
912
        /**
913
         * Add productTag.
914
         *
915
         * @param \Eccube\Entity\ProductTag $productTag
916
         *
917 18
         * @return Product
918
         */
919 18
        public function addProductTag(\Eccube\Entity\ProductTag $productTag)
920
        {
921 18
            $this->ProductTag[] = $productTag;
922
923
            return $this;
924
        }
925
926
        /**
927
         * Remove productTag.
928
         *
929
         * @param \Eccube\Entity\ProductTag $productTag
930
         *
931 2
         * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
932
         */
933 2
        public function removeProductTag(\Eccube\Entity\ProductTag $productTag)
934
        {
935
            return $this->ProductTag->removeElement($productTag);
936
        }
937
938
        /**
939
         * Get productTag.
940
         *
941 40
         * @return \Doctrine\Common\Collections\Collection
942
         */
943 40
        public function getProductTag()
944
        {
945
            return $this->ProductTag;
946
        }
947
948
        /**
949
         * Get Tag
950
         * フロント側タグsort_no順の配列を作成する
951
         *
952 31
         * @return []Tag
0 ignored issues
show
Documentation introduced by
The doc-type []Tag could not be parsed: Unknown type name "" at position 0. [(view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
953
         */
954 31
        public function getTags()
955
        {
956 31
            $tags = [];
957 1
958
            foreach ($this->getProductTag() as $productTag) {
959
                $tags[] = $productTag->getTag();
960 31
            }
961
962 31
            usort($tags, function (Tag $tag1, Tag $tag2) {
963
                return $tag1->getSortNo() < $tag2->getSortNo();
964 31
            });
965
966
            return $tags;
967
        }
968
969
        /**
970
         * Add customerFavoriteProduct.
971
         *
972
         * @param \Eccube\Entity\CustomerFavoriteProduct $customerFavoriteProduct
973
         *
974
         * @return Product
975
         */
976
        public function addCustomerFavoriteProduct(\Eccube\Entity\CustomerFavoriteProduct $customerFavoriteProduct)
977
        {
978
            $this->CustomerFavoriteProducts[] = $customerFavoriteProduct;
979
980
            return $this;
981
        }
982
983
        /**
984
         * Remove customerFavoriteProduct.
985
         *
986
         * @param \Eccube\Entity\CustomerFavoriteProduct $customerFavoriteProduct
987
         *
988
         * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
989
         */
990
        public function removeCustomerFavoriteProduct(\Eccube\Entity\CustomerFavoriteProduct $customerFavoriteProduct)
991
        {
992
            return $this->CustomerFavoriteProducts->removeElement($customerFavoriteProduct);
993
        }
994
995
        /**
996
         * Get customerFavoriteProducts.
997
         *
998
         * @return \Doctrine\Common\Collections\Collection
999
         */
1000
        public function getCustomerFavoriteProducts()
1001
        {
1002
            return $this->CustomerFavoriteProducts;
1003
        }
1004
1005
        /**
1006
         * Set creator.
1007
         *
1008
         * @param \Eccube\Entity\Member|null $creator
1009
         *
1010 408
         * @return Product
1011
         */
1012 408
        public function setCreator(\Eccube\Entity\Member $creator = null)
1013
        {
1014 408
            $this->Creator = $creator;
1015
1016
            return $this;
1017
        }
1018
1019
        /**
1020
         * Get creator.
1021
         *
1022 12
         * @return \Eccube\Entity\Member|null
1023
         */
1024 12
        public function getCreator()
1025
        {
1026
            return $this->Creator;
1027
        }
1028
1029
        /**
1030
         * Set status.
1031
         *
1032
         * @param \Eccube\Entity\Master\ProductStatus|null $status
1033
         *
1034 406
         * @return Product
1035
         */
1036 406
        public function setStatus(\Eccube\Entity\Master\ProductStatus $status = null)
1037
        {
1038 406
            $this->Status = $status;
1039
1040
            return $this;
1041
        }
1042
1043
        /**
1044
         * Get status.
1045
         *
1046 106
         * @return \Eccube\Entity\Master\ProductStatus|null
1047
         */
1048 106
        public function getStatus()
1049
        {
1050
            return $this->Status;
1051
        }
1052
    }
1053
}
1054