Failed Conditions
Push — fix-message-id-run-test ( 4fe74b...be7b70 )
by Kiyotaka
15:13 queued 09:02
created

Product::_calc()   D

Complexity

Conditions 18
Paths 55

Size

Total Lines 68

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 18
nc 55
nop 0
dl 0
loc 68
rs 4.8666
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
                            if ($ProductClass->getClassCategory2()) {
109
                                $this->classCategories1[$ProductClass->getClassCategory1()->getId()] = $ProductClass->getClassCategory1()->getName();
110
                                $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
                        }
115
                    }
116
                    $i++;
117
                }
118
                $this->_calc = true;
119
            }
120
        }
121
122
        /**
123
         * Is Enable
124
         *
125
         * @return bool
126
         */
127
        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
         * @return string
136
         */
137
        public function getClassName1()
138
        {
139
            $this->_calc();
140
141
            return $this->className1;
142
        }
143
144
        /**
145
         * Get ClassName2
146
         *
147
         * @return string
148
         */
149
        public function getClassName2()
150
        {
151
            $this->_calc();
152
153
            return $this->className2;
154
        }
155
156
        /**
157
         * Get getClassCategories1
158
         *
159
         * @return array
160
         */
161
        public function getClassCategories1()
162
        {
163
            $this->_calc();
164
165
            return $this->classCategories1;
166
        }
167
168
        public function getClassCategories1AsFlip()
169
        {
170
            return array_flip($this->getClassCategories1());
171
        }
172
173
        /**
174
         * Get getClassCategories2
175
         *
176
         * @return array
177
         */
178
        public function getClassCategories2($class_category1)
179
        {
180
            $this->_calc();
181
182
            return isset($this->classCategories2[$class_category1]) ? $this->classCategories2[$class_category1] : [];
183
        }
184
185
        public function getClassCategories2AsFlip($class_category1)
186
        {
187
            return array_flip($this->getClassCategories2($class_category1));
188
        }
189
190
        /**
191
         * Get StockFind
192
         *
193
         * @return bool
194
         */
195
        public function getStockFind()
196
        {
197
            $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
         * @return integer
254
         */
255 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
            $this->_calc();
258
259
            if (count($this->price01) == 0) {
260
                return null;
261
            }
262
263
            return min($this->price01);
264
        }
265
266
        /**
267
         * Get Price01 max
268
         *
269
         * @return integer
270
         */
271 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
            $this->_calc();
274
275
            if (count($this->price01) == 0) {
276
                return null;
277
            }
278
279
            return max($this->price01);
280
        }
281
282
        /**
283
         * Get Price02 min
284
         *
285
         * @return integer
286
         */
287
        public function getPrice02Min()
288
        {
289
            $this->_calc();
290
291
            return min($this->price02);
292
        }
293
294
        /**
295
         * Get Price02 max
296
         *
297
         * @return integer
298
         */
299
        public function getPrice02Max()
300
        {
301
            $this->_calc();
302
303
            return max($this->price02);
304
        }
305
306
        /**
307
         * Get Price01IncTax min
308
         *
309
         * @return integer
310
         */
311
        public function getPrice01IncTaxMin()
312
        {
313
            $this->_calc();
314
315
            return min($this->price01IncTaxs);
316
        }
317
318
        /**
319
         * Get Price01IncTax max
320
         *
321
         * @return integer
322
         */
323
        public function getPrice01IncTaxMax()
324
        {
325
            $this->_calc();
326
327
            return max($this->price01IncTaxs);
328
        }
329
330
        /**
331
         * Get Price02IncTax min
332
         *
333
         * @return integer
334
         */
335
        public function getPrice02IncTaxMin()
336
        {
337
            $this->_calc();
338
339
            return min($this->price02IncTaxs);
340
        }
341
342
        /**
343
         * Get Price02IncTax max
344
         *
345
         * @return integer
346
         */
347
        public function getPrice02IncTaxMax()
348
        {
349
            $this->_calc();
350
351
            return max($this->price02IncTaxs);
352
        }
353
354
        /**
355
         * Get Product_code min
356
         *
357
         * @return integer
358
         */
359 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
            $this->_calc();
362
363
            $codes = [];
364
            foreach ($this->codes as $code) {
365
                if (!is_null($code)) {
366
                    $codes[] = $code;
367
                }
368
            }
369
370
            return count($codes) ? min($codes) : null;
371
        }
372
373
        /**
374
         * Get Product_code max
375
         *
376
         * @return integer
377
         */
378 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
            $this->_calc();
381
382
            $codes = [];
383
            foreach ($this->codes as $code) {
384
                if (!is_null($code)) {
385
                    $codes[] = $code;
386
                }
387
            }
388
389
            return count($codes) ? max($codes) : null;
390
        }
391
392
        public function getMainListImage()
393
        {
394
            $ProductImages = $this->getProductImage();
395
396
            return empty($ProductImages) ? null : $ProductImages[0];
397
        }
398
399
        public function getMainFileName()
400
        {
401
            if (count($this->ProductImage) > 0) {
402
                return $this->ProductImage[0];
403
            } else {
404
                return null;
405
            }
406
        }
407
408
        public function hasProductClass()
409
        {
410
            foreach ($this->ProductClasses as $ProductClass) {
411
                if (!$ProductClass->isVisible()) {
412
                    continue;
413
                }
414
                if (!is_null($ProductClass->getClassCategory1())) {
415
                    return true;
416
                }
417
            }
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
         * Constructor
547
         */
548
        public function __construct()
549
        {
550
            $this->ProductCategories = new \Doctrine\Common\Collections\ArrayCollection();
551
            $this->ProductClasses = new \Doctrine\Common\Collections\ArrayCollection();
552
            $this->ProductImage = new \Doctrine\Common\Collections\ArrayCollection();
553
            $this->ProductTag = new \Doctrine\Common\Collections\ArrayCollection();
554
            $this->CustomerFavoriteProducts = new \Doctrine\Common\Collections\ArrayCollection();
555
        }
556
557
        public function __clone()
558
        {
559
            $this->id = null;
560
        }
561
562
        public function copy()
563
        {
564
            // コピー対象外
565
            $this->CustomerFavoriteProducts = new ArrayCollection();
566
567
            $Categories = $this->getProductCategories();
568
            $this->ProductCategories = new ArrayCollection();
569
            foreach ($Categories as $Category) {
570
                $CopyCategory = clone $Category;
571
                $this->addProductCategory($CopyCategory);
572
                $CopyCategory->setProduct($this);
573
            }
574
575
            $Classes = $this->getProductClasses();
576
            $this->ProductClasses = new ArrayCollection();
577
            foreach ($Classes as $Class) {
578
                $CopyClass = clone $Class;
579
                $this->addProductClass($CopyClass);
580
                $CopyClass->setProduct($this);
581
            }
582
583
            $Images = $this->getProductImage();
584
            $this->ProductImage = new ArrayCollection();
585
            foreach ($Images as $Image) {
586
                $CloneImage = clone $Image;
587
                $this->addProductImage($CloneImage);
588
                $CloneImage->setProduct($this);
589
            }
590
591
            $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
            }
598
599
            return $this;
600
        }
601
602
        /**
603
         * Get id.
604
         *
605
         * @return int
606
         */
607
        public function getId()
608
        {
609
            return $this->id;
610
        }
611
612
        /**
613
         * Set name.
614
         *
615
         * @param string $name
616
         *
617
         * @return Product
618
         */
619
        public function setName($name)
620
        {
621
            $this->name = $name;
622
623
            return $this;
624
        }
625
626
        /**
627
         * Get name.
628
         *
629
         * @return string
630
         */
631
        public function getName()
632
        {
633
            return $this->name;
634
        }
635
636
        /**
637
         * Set note.
638
         *
639
         * @param string|null $note
640
         *
641
         * @return Product
642
         */
643
        public function setNote($note = null)
644
        {
645
            $this->note = $note;
646
647
            return $this;
648
        }
649
650
        /**
651
         * Get note.
652
         *
653
         * @return string|null
654
         */
655
        public function getNote()
656
        {
657
            return $this->note;
658
        }
659
660
        /**
661
         * Set descriptionList.
662
         *
663
         * @param string|null $descriptionList
664
         *
665
         * @return Product
666
         */
667
        public function setDescriptionList($descriptionList = null)
668
        {
669
            $this->description_list = $descriptionList;
670
671
            return $this;
672
        }
673
674
        /**
675
         * Get descriptionList.
676
         *
677
         * @return string|null
678
         */
679
        public function getDescriptionList()
680
        {
681
            return $this->description_list;
682
        }
683
684
        /**
685
         * Set descriptionDetail.
686
         *
687
         * @param string|null $descriptionDetail
688
         *
689
         * @return Product
690
         */
691
        public function setDescriptionDetail($descriptionDetail = null)
692
        {
693
            $this->description_detail = $descriptionDetail;
694
695
            return $this;
696
        }
697
698
        /**
699
         * Get descriptionDetail.
700
         *
701
         * @return string|null
702
         */
703
        public function getDescriptionDetail()
704
        {
705
            return $this->description_detail;
706
        }
707
708
        /**
709
         * Set searchWord.
710
         *
711
         * @param string|null $searchWord
712
         *
713
         * @return Product
714
         */
715
        public function setSearchWord($searchWord = null)
716
        {
717
            $this->search_word = $searchWord;
718
719
            return $this;
720
        }
721
722
        /**
723
         * Get searchWord.
724
         *
725
         * @return string|null
726
         */
727
        public function getSearchWord()
728
        {
729
            return $this->search_word;
730
        }
731
732
        /**
733
         * Set freeArea.
734
         *
735
         * @param string|null $freeArea
736
         *
737
         * @return Product
738
         */
739
        public function setFreeArea($freeArea = null)
740
        {
741
            $this->free_area = $freeArea;
742
743
            return $this;
744
        }
745
746
        /**
747
         * Get freeArea.
748
         *
749
         * @return string|null
750
         */
751
        public function getFreeArea()
752
        {
753
            return $this->free_area;
754
        }
755
756
        /**
757
         * Set createDate.
758
         *
759
         * @param \DateTime $createDate
760
         *
761
         * @return Product
762
         */
763
        public function setCreateDate($createDate)
764
        {
765
            $this->create_date = $createDate;
766
767
            return $this;
768
        }
769
770
        /**
771
         * Get createDate.
772
         *
773
         * @return \DateTime
774
         */
775
        public function getCreateDate()
776
        {
777
            return $this->create_date;
778
        }
779
780
        /**
781
         * Set updateDate.
782
         *
783
         * @param \DateTime $updateDate
784
         *
785
         * @return Product
786
         */
787
        public function setUpdateDate($updateDate)
788
        {
789
            $this->update_date = $updateDate;
790
791
            return $this;
792
        }
793
794
        /**
795
         * Get updateDate.
796
         *
797
         * @return \DateTime
798
         */
799
        public function getUpdateDate()
800
        {
801
            return $this->update_date;
802
        }
803
804
        /**
805
         * Add productCategory.
806
         *
807
         * @param \Eccube\Entity\ProductCategory $productCategory
808
         *
809
         * @return Product
810
         */
811
        public function addProductCategory(\Eccube\Entity\ProductCategory $productCategory)
812
        {
813
            $this->ProductCategories[] = $productCategory;
814
815
            return $this;
816
        }
817
818
        /**
819
         * Remove productCategory.
820
         *
821
         * @param \Eccube\Entity\ProductCategory $productCategory
822
         *
823
         * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
824
         */
825
        public function removeProductCategory(\Eccube\Entity\ProductCategory $productCategory)
826
        {
827
            return $this->ProductCategories->removeElement($productCategory);
828
        }
829
830
        /**
831
         * Get productCategories.
832
         *
833
         * @return \Doctrine\Common\Collections\Collection
834
         */
835
        public function getProductCategories()
836
        {
837
            return $this->ProductCategories;
838
        }
839
840
        /**
841
         * Add productClass.
842
         *
843
         * @param \Eccube\Entity\ProductClass $productClass
844
         *
845
         * @return Product
846
         */
847
        public function addProductClass(\Eccube\Entity\ProductClass $productClass)
848
        {
849
            $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
         * @return \Doctrine\Common\Collections\Collection
870
         */
871
        public function getProductClasses()
872
        {
873
            return $this->ProductClasses;
874
        }
875
876
        /**
877
         * Add productImage.
878
         *
879
         * @param \Eccube\Entity\ProductImage $productImage
880
         *
881
         * @return Product
882
         */
883
        public function addProductImage(\Eccube\Entity\ProductImage $productImage)
884
        {
885
            $this->ProductImage[] = $productImage;
886
887
            return $this;
888
        }
889
890
        /**
891
         * Remove productImage.
892
         *
893
         * @param \Eccube\Entity\ProductImage $productImage
894
         *
895
         * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
896
         */
897
        public function removeProductImage(\Eccube\Entity\ProductImage $productImage)
898
        {
899
            return $this->ProductImage->removeElement($productImage);
900
        }
901
902
        /**
903
         * Get productImage.
904
         *
905
         * @return \Doctrine\Common\Collections\Collection
906
         */
907
        public function getProductImage()
908
        {
909
            return $this->ProductImage;
910
        }
911
912
        /**
913
         * Add productTag.
914
         *
915
         * @param \Eccube\Entity\ProductTag $productTag
916
         *
917
         * @return Product
918
         */
919
        public function addProductTag(\Eccube\Entity\ProductTag $productTag)
920
        {
921
            $this->ProductTag[] = $productTag;
922
923
            return $this;
924
        }
925
926
        /**
927
         * Remove productTag.
928
         *
929
         * @param \Eccube\Entity\ProductTag $productTag
930
         *
931
         * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
932
         */
933
        public function removeProductTag(\Eccube\Entity\ProductTag $productTag)
934
        {
935
            return $this->ProductTag->removeElement($productTag);
936
        }
937
938
        /**
939
         * Get productTag.
940
         *
941
         * @return \Doctrine\Common\Collections\Collection
942
         */
943
        public function getProductTag()
944
        {
945
            return $this->ProductTag;
946
        }
947
948
        /**
949
         * Get Tag
950
         * フロント側タグsort_no順の配列を作成する
951
         *
952
         * @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
        public function getTags()
955
        {
956
            $tags = [];
957
958
            foreach ($this->getProductTag() as $productTag) {
959
                $tags[] = $productTag->getTag();
960
            }
961
962
            usort($tags, function (Tag $tag1, Tag $tag2) {
963
                return $tag1->getSortNo() < $tag2->getSortNo();
964
            });
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
         * @return Product
1011
         */
1012
        public function setCreator(\Eccube\Entity\Member $creator = null)
1013
        {
1014
            $this->Creator = $creator;
1015
1016
            return $this;
1017
        }
1018
1019
        /**
1020
         * Get creator.
1021
         *
1022
         * @return \Eccube\Entity\Member|null
1023
         */
1024
        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
         * @return Product
1035
         */
1036
        public function setStatus(\Eccube\Entity\Master\ProductStatus $status = null)
1037
        {
1038
            $this->Status = $status;
1039
1040
            return $this;
1041
        }
1042
1043
        /**
1044
         * Get status.
1045
         *
1046
         * @return \Eccube\Entity\Master\ProductStatus|null
1047
         */
1048
        public function getStatus()
1049
        {
1050
            return $this->Status;
1051
        }
1052
    }
1053
}
1054