Failed Conditions
Pull Request — experimental/sf (#31)
by Kentaro
06:59
created

Product::_calc()   C

Complexity

Conditions 17
Paths 45

Size

Total Lines 66

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 17
nc 45
nop 0
dl 0
loc 66
rs 5.2166
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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