Passed
Push — master ( 79d3da...c4324c )
by Joachim
12:50
created

Product::getPrices()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 1
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Loevgaard\DandomainFoundation\Entity;
4
5
use Assert\Assert;
6
use Doctrine\Common\Collections\ArrayCollection;
7
use Doctrine\ORM\Mapping as ORM;
8
use Knp\DoctrineBehaviors\Model\SoftDeletable\SoftDeletable;
9
use Knp\DoctrineBehaviors\Model\Timestampable\Timestampable;
10
use Knp\DoctrineBehaviors\Model\Translatable\Translatable;
11
use Loevgaard\DandomainFoundation\Entity\Generated\CategoryInterface;
0 ignored issues
show
Bug introduced by
The type Loevgaard\DandomainFound...rated\CategoryInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Loevgaard\DandomainFoundation\Entity\Generated\CurrencyInterface;
0 ignored issues
show
Bug introduced by
The type Loevgaard\DandomainFound...rated\CurrencyInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use Loevgaard\DandomainFoundation\Entity\Generated\ManufacturerInterface;
0 ignored issues
show
Bug introduced by
The type Loevgaard\DandomainFound...d\ManufacturerInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use Loevgaard\DandomainFoundation\Entity\Generated\MediumInterface;
0 ignored issues
show
Bug introduced by
The type Loevgaard\DandomainFound...nerated\MediumInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
use Loevgaard\DandomainFoundation\Entity\Generated\PriceInterface;
0 ignored issues
show
Bug introduced by
The type Loevgaard\DandomainFound...enerated\PriceInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
use Loevgaard\DandomainFoundation\Entity\Generated\ProductInterface;
0 ignored issues
show
Bug introduced by
The type Loevgaard\DandomainFound...erated\ProductInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
use Loevgaard\DandomainFoundation\Entity\Generated\ProductRelationInterface;
0 ignored issues
show
Bug introduced by
The type Loevgaard\DandomainFound...roductRelationInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
use Loevgaard\DandomainFoundation\Entity\Generated\ProductTrait;
0 ignored issues
show
Bug introduced by
The type Loevgaard\DandomainFound...\Generated\ProductTrait was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
19
use Loevgaard\DandomainFoundation\Entity\Generated\ProductTranslationInterface;
0 ignored issues
show
Bug introduced by
The type Loevgaard\DandomainFound...uctTranslationInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
use Loevgaard\DandomainFoundation\Entity\Generated\ProductTypeInterface;
0 ignored issues
show
Bug introduced by
The type Loevgaard\DandomainFound...ed\ProductTypeInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
use Loevgaard\DandomainFoundation\Entity\Generated\SegmentInterface;
0 ignored issues
show
Bug introduced by
The type Loevgaard\DandomainFound...erated\SegmentInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
22
use Loevgaard\DandomainFoundation\Entity\Generated\VariantGroupInterface;
0 ignored issues
show
Bug introduced by
The type Loevgaard\DandomainFound...d\VariantGroupInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
23
use Loevgaard\DandomainFoundation\Entity\Generated\VariantInterface;
0 ignored issues
show
Bug introduced by
The type Loevgaard\DandomainFound...erated\VariantInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
24
25
/**
26
 * @ORM\Entity()
27
 * @ORM\Table(name="ldf_products", indexes={
28
 *     @ORM\Index(columns={"is_variant_master"})
29
 * })
30
 * @ORM\HasLifecycleCallbacks()
31
 * @method ProductTranslationInterface translate(string $locale = null, bool $fallbackToDefault = true)
32
 */
33
class Product extends AbstractEntity implements ProductInterface
34
{
35
    use ProductTrait;
36
    use Timestampable;
37
    use SoftDeletable;
38
    use Translatable;
39
40
    protected $hydrateConversions = [
41
        'id' => 'externalId'
42
    ];
43
44
    /**
45
     * @var int
46
     *
47
     * @ORM\Id
48
     * @ORM\GeneratedValue
49
     * @ORM\Column(type="integer")
50
     **/
51
    protected $id;
52
53
    /**
54
     * @var int
55
     *
56
     * @ORM\Column(type="integer", nullable=true, unique=true)
57
     */
58
    protected $externalId;
59
60
    /**
61
     * @var string|null
62
     *
63
     * @ORM\Column(nullable=true, type="string", length=191)
64
     */
65
    protected $barCodeNumber;
66
67
    /**
68
     * @var array|null
69
     *
70
     * @ORM\Column(nullable=true, type="json")
71
     */
72
    protected $categoryIdList;
73
74
    /**
75
     * @var string|null
76
     *
77
     * @ORM\Column(nullable=true, type="string", length=191)
78
     */
79
    protected $comments;
80
81
    /**
82
     * @var float|null
83
     *
84
     * @ORM\Column(nullable=true, type="decimal", precision=12, scale=2)
85
     */
86
    protected $costPrice;
87
88
    /**
89
     * @var \DateTimeImmutable|null
90
     *
91
     * @ORM\Column(nullable=true, type="datetime_immutable", options={"comment"="Created info from Dandomain"})
92
     */
93
    protected $created;
94
95
    /**
96
     * @var string|null
97
     *
98
     * @ORM\Column(nullable=true, type="string", length=191, options={"comment"="Created by info from Dandomain"})
99
     */
100
    protected $createdBy;
101
102
    /**
103
     * @var int|null
104
     *
105
     * @ORM\Column(nullable=true, type="integer")
106
     */
107
    protected $defaultCategoryId;
108
109
    /**
110
     * @var array|null
111
     *
112
     * @ORM\Column(nullable=true, type="json")
113
     */
114
    protected $disabledVariantIdList;
115
116
    /**
117
     * @var string|null
118
     *
119
     * @ORM\Column(nullable=true, type="string", length=191)
120
     */
121
    protected $edbPriserProductNumber;
122
123
    /**
124
     * @var string|null
125
     *
126
     * @ORM\Column(nullable=true, type="string", length=191)
127
     */
128
    protected $fileSaleLink;
129
130
    /**
131
     * @var string|null
132
     *
133
     * @ORM\Column(nullable=true, type="string", length=191)
134
     */
135
    protected $googleFeedCategory;
136
137
    /**
138
     * @var bool|null
139
     *
140
     * @ORM\Column(nullable=true, type="boolean")
141
     */
142
    protected $isGiftCertificate;
143
144
    /**
145
     * @var bool|null
146
     *
147
     * @ORM\Column(nullable=true, type="boolean")
148
     */
149
    protected $isModified;
150
151
    /**
152
     * @var bool|null
153
     *
154
     * @ORM\Column(nullable=true, type="boolean")
155
     */
156
    protected $isRateVariants;
157
158
    /**
159
     * @var bool|null
160
     *
161
     * @ORM\Column(nullable=true, type="boolean")
162
     */
163
    protected $isReviewVariants;
164
165
    /**
166
     * @var bool|null
167
     *
168
     * @ORM\Column(name="is_variant_master", nullable=true, type="boolean")
169
     */
170
    protected $isVariantMaster;
171
172
    /**
173
     * @var string|null
174
     *
175
     * @ORM\Column(nullable=true, type="string", length=191)
176
     */
177
    protected $locationNumber;
178
179
    /**
180
     * @var array|null
181
     *
182
     * @ORM\Column(nullable=true, type="json")
183
     */
184
    protected $manufacturereIdList;
185
186
    /**
187
     * @var int|null
188
     *
189
     * @ORM\Column(nullable=true, type="integer")
190
     */
191
    protected $maxBuyAmount;
192
193
    /**
194
     * @var int|null
195
     *
196
     * @ORM\Column(nullable=true, type="integer")
197
     */
198
    protected $minBuyAmount;
199
200
    /**
201
     * @var int|null
202
     *
203
     * @ORM\Column(nullable=true, type="integer")
204
     */
205
    protected $minBuyAmountB2B;
206
207
    /**
208
     * The product number
209
     *
210
     * @var string
211
     *
212
     * @ORM\Column(type="string", length=191, unique=true)
213
     */
214
    protected $number;
215
216
    /**
217
     * @var string|null
218
     *
219
     * @ORM\Column(nullable=true, type="string", length=191)
220
     */
221
    protected $picture;
222
223
    /**
224
     * @var int|null
225
     *
226
     * @ORM\Column(nullable=true, type="integer")
227
     */
228
    protected $salesCount;
229
230
    /**
231
     * @var array|null
232
     *
233
     * @ORM\Column(nullable=true, type="json")
234
     */
235
    protected $segmentIdList;
236
237
    /**
238
     * @var int|null
239
     *
240
     * @ORM\Column(nullable=true, type="integer")
241
     */
242
    protected $sortOrder;
243
244
    /**
245
     * @var int|null
246
     *
247
     * @ORM\Column(nullable=true, type="integer")
248
     */
249
    protected $stockCount;
250
251
    /**
252
     * @var int|null
253
     *
254
     * @ORM\Column(nullable=true, type="integer")
255
     */
256
    protected $stockLimit;
257
258
    /**
259
     * @var int|null
260
     *
261
     * @ORM\Column(nullable=true, type="integer")
262
     */
263
    protected $typeId;
264
265
    /**
266
     * @var \DateTimeImmutable|null
267
     *
268
     * @ORM\Column(nullable=true, type="datetime_immutable", options={"comment"="Updated info from Dandomain"})
269
     */
270
    protected $updated;
271
272
    /**
273
     * @var string|null
274
     *
275
     * @ORM\Column(nullable=true, type="string", length=191, options={"comment"="Updated by info from Dandomain"})
276
     */
277
    protected $updatedBy;
278
279
    /**
280
     * @var array|null
281
     *
282
     * @ORM\Column(nullable=true, type="json")
283
     */
284
    protected $variantGroupIdList;
285
286
    /**
287
     * @var array|null
288
     *
289
     * @ORM\Column(nullable=true, type="json")
290
     */
291
    protected $variantIdList;
292
293
    /**
294
     * @var int|null
295
     *
296
     * @ORM\Column(nullable=true, type="string", length=191)
297
     */
298
    protected $variantMasterId;
299
300
    /**
301
     * @var string|null
302
     *
303
     * @ORM\Column(nullable=true, type="string", length=191)
304
     */
305
    protected $vendorNumber;
306
307
    /**
308
     * @var int|null
309
     *
310
     * @ORM\Column(nullable=true, type="integer")
311
     */
312
    protected $weight;
313
314
    /**
315
     * @var Category[]|ArrayCollection
316
     *
317
     * @ORM\ManyToMany(targetEntity="Category", inversedBy="products")
318
     * @ORM\JoinTable(name="ldf_products_categories")
319
     */
320
    protected $categories;
321
322
    /**
323
     * @var Variant[]|ArrayCollection
324
     */
325
    protected $disabledVariants;
326
327
    /**
328
     * @var Manufacturer[]|ArrayCollection
329
     *
330
     * @ORM\JoinTable(name="ldf_product_manufacturer")
331
     * @ORM\ManyToMany(cascade={"persist"}, inversedBy="products", targetEntity="Manufacturer")
332
     */
333
    protected $manufacturers;
334
335
    /**
336
     * @var Medium[]|ArrayCollection
337
     */
338
    protected $media;
339
340
    /**
341
     * Some products in Dandomain doesn't have prices because they are not really products, i.e. discounts, shipping info etc
342
     * Dandomain treat these as products on an order, which of course is wrong, but we handle them
343
     *
344
     * @var bool
345
     *
346
     * @ORM\Column(type="boolean")
347
     */
348
    protected $priceLess;
349
350
    /**
351
     * @var PriceInterface[]|ArrayCollection
352
     *
353
     * @ORM\OneToMany(targetEntity="Price", mappedBy="product", cascade={"persist", "remove"}, orphanRemoval=true)
354
     */
355
    protected $prices;
356
357
    /**
358
     * @var ProductRelation[]|ArrayCollection
359
     */
360
    protected $productRelations;
361
362
    /**
363
     * @var ProductType
364
     */
365
    protected $productType;
366
367
    /**
368
     * @var Segment[]|ArrayCollection
369
     */
370
    protected $segments;
371
372
    /**
373
     * @var VariantGroup[]|ArrayCollection
374
     *
375
     * @ORM\JoinTable(name="ldf_product_variant_group")
376
     * @ORM\ManyToMany(cascade={"persist"}, inversedBy="products", targetEntity="VariantGroup")
377
     */
378
    protected $variantGroups;
379
380
    /**
381
     * @var Variant[]|ArrayCollection
382
     */
383
    protected $variants;
384
385
    /**
386
     * This is the master for this product
387
     *
388
     * @var Product|null
389
     *
390 12
     * @ORM\ManyToOne(targetEntity="Product", inversedBy="children")
391
     */
392 12
    protected $parent;
393 12
394 12
    /**
395 12
     * This is the children (i.e. variants) of this products
396 12
     *
397 12
     * @var Product[]|ArrayCollection
398 12
     *
399 12
     * @ORM\OneToMany(targetEntity="Product", mappedBy="parent")
400 12
     */
401 12
    protected $children;
402 12
403
    public function __construct()
404
    {
405
        $this->priceLess = false;
406
        $this->categories = new ArrayCollection();
407
        $this->disabledVariants = new ArrayCollection();
408
        $this->manufacturers = new ArrayCollection();
409
        $this->media = new ArrayCollection();
410
        $this->prices = new ArrayCollection();
411
        $this->productRelations = new ArrayCollection();
412
        $this->segments = new ArrayCollection();
413
        $this->variants = new ArrayCollection();
414
        $this->variantGroups = new ArrayCollection();
415
        $this->children = new ArrayCollection();
416
    }
417
418
    public function __toString()
419
    {
420
        return (string)$this->number;
421
    }
422
423
    /**
424
     * @ORM\PrePersist()
425 3
     * @ORM\PreUpdate()
426
     */
427 3
    public function validate()
428 3
    {
429
        Assert::that($this->number)
430
            ->string('The number needs to be string', 'number')
431 3
            ->maxLength(191, 'The number must have a max length of 191');
432 3
        Assert::thatNullOr($this->externalId)->integer('The external id can only be null or an integer', 'externalId');
433
434
        if (is_null($this->externalId)) {
0 ignored issues
show
introduced by
The condition is_null($this->externalId) can never be true.
Loading history...
435 3
            Assert::that($this->isDeleted())->true('The external id can only be null if the product is marked as deleted', 'externalId');
436 3
        }
437
438
        if(!$this->priceLess) {
439
            Assert::that($this->prices->count())->greaterThan(0, 'When the product is not "price less" the product needs to have at least one price');
440
        }
441
    }
442
443
    public function hydrate(array $data, bool $useConversions = false, $scalarsOnly = true)
444
    {
445
        if (isset($data['created'])) {
446
            $data['created'] = $this->getDateTimeFromJson($data['created']);
447
        }
448
449
        if (isset($data['updated'])) {
450
            $data['updated'] = $this->getDateTimeFromJson($data['updated']);
451
        }
452
453
        parent::hydrate($data, $useConversions, $scalarsOnly);
454
    }
455
456
    /*
457
     * Collection/relation methods
458
     */
459
460
    public function addDisabledVariant(VariantInterface $variant) : ProductInterface
461
    {
462
        if (!$this->disabledVariants->contains($variant)) {
463
            $this->disabledVariants->add($variant);
464
        }
465
466
        return $this;
467
    }
468
469
    public function addMedium(MediumInterface $medium) : ProductInterface
470
    {
471
        if (!$this->media->contains($medium)) {
472
            $this->media->add($medium);
473
        }
474
475
        return $this;
476
    }
477
478
    public function addCategory(CategoryInterface $category) : ProductInterface
479
    {
480
        if (!$this->categories->contains($category)) {
481
            $this->categories->add($category);
482
        }
483
484
        return $this;
485
    }
486
487
    public function addManufacturer(ManufacturerInterface $manufacturer) : ProductInterface
488
    {
489
        if (!$this->hasManufacturer($manufacturer)) {
490
            $this->manufacturers->add($manufacturer);
491
        }
492
493
        return $this;
494
    }
495
496
    public function removeManufacturer(ManufacturerInterface $manufacturer) : bool
497
    {
498
        return $this->manufacturers->removeElement($manufacturer);
499
    }
500
501
    public function hasManufacturer(ManufacturerInterface $manufacturer) : bool
502
    {
503
        return $this->manufacturers->exists(function ($key, ManufacturerInterface $element) use ($manufacturer) {
504
            return $element->getExternalId() === $manufacturer->getExternalId();
505
        });
506
    }
507
508
    public function addVariantGroup(VariantGroupInterface $variantGroup) : ProductInterface
509
    {
510
        if (!$this->hasVariantGroup($variantGroup)) {
511
            $this->variantGroups->add($variantGroup);
512
        }
513
514
        return $this;
515
    }
516
517
    public function removeVariantGroup(VariantGroupInterface $variantGroup) : bool
518
    {
519
        return $this->variantGroups->removeElement($variantGroup);
520
    }
521
522
    public function hasVariantGroup($variantGroup) : bool
523
    {
524
        if ($variantGroup instanceof VariantGroupInterface) {
525
            $variantGroup = $variantGroup->getExternalId();
526
        }
527
528
        return $this->variantGroups->exists(function ($key, VariantGroupInterface $element) use ($variantGroup) {
529
            return $element->getExternalId() === $variantGroup;
530
        });
531
    }
532
533
    public function addPrice(PriceInterface $price) : ProductInterface
534
    {
535
        if(!$this->prices->contains($price)) {
536
            $this->prices->add($price);
537
            $price->setProduct($this);
538
        }
539
540
        return $this;
541
    }
542
543
    /**
544
     * @param PriceInterface[] $prices
545
     */
546
    public function updatePrices(array $prices) : void
547
    {
548
        // this holds the final array of prices, whether updated or added
549
        $finalPrices = [];
550
551
        foreach ($prices as $price) {
552
            $existingPrice = $this->findPrice($price);
553
554
            if($existingPrice) {
555
                $existingPrice->copyProperties($price);
556
                $existingPrice->setProduct($this);
557
                $finalPrices[] = $existingPrice;
558
            } else {
559
                $this->addPrice($price);
560
                $price->setProduct($this);
561
                $finalPrices[] = $price;
562
            }
563
        }
564
565
        foreach ($this->prices as $price) {
566
            if(!in_array($price, $finalPrices, true)) {
567
                $this->removePrice($price);
568
            }
569
        }
570
    }
571
572
    public function removePrice(PriceInterface $price) : bool
573
    {
574
        $price->setProduct(null);
575
        return $this->prices->removeElement($price);
576
    }
577
578
    /**
579
     * This method will try to find a price based on the unique constraint defined in price
580
     *
581
     * @param PriceInterface $searchPrice
582
     * @return PriceInterface|null
583
     */
584 6
    protected function findPrice(PriceInterface $searchPrice) : ?PriceInterface
585
    {
586 6
        foreach ($this->prices as $price) {
587
            if($price->getAmount() == $searchPrice->getAmount() && $price->getB2bGroupId() == $searchPrice->getB2bGroupId() && $price->getCurrency()->getId() == $searchPrice->getCurrency()->getId()) {
588
                return $price;
589
            }
590
        }
591
592
        return null;
593 3
    }
594
595 3
    /**
596 3
     * Will try to find a price based on currency
597
     *
598
     * @param string|\Money\Currency|CurrencyInterface $currency
599
     * @return PriceInterface|null
600
     */
601
    public function findPriceByCurrency($currency) : ?PriceInterface
602 6
    {
603
        if($currency instanceof \Money\Currency) {
604 6
            $currency = $currency->getCode();
605
        } elseif ($currency instanceof CurrencyInterface) {
0 ignored issues
show
introduced by
The condition $currency instanceof Loe...rated\CurrencyInterface can never be true since $currency is never a sub-type of Loevgaard\DandomainFound...rated\CurrencyInterface.
Loading history...
606
            $currency = $currency->getIsoCodeAlpha();
607
        }
608
609
        if(!is_string($currency)) {
0 ignored issues
show
introduced by
The condition ! is_string($currency) can never be true.
Loading history...
610
            throw new \InvalidArgumentException('$currency has to be a string');
611 3
        }
612
613 3
        foreach ($this->prices as $price) {
614 3
            if($price->getCurrency()->getIsoCodeAlpha() === $currency) {
615
                return $price;
616
            }
617
        }
618
619
        return null;
620 3
    }
621
622 3
    public function addProductRelation(ProductRelationInterface $productRelation) : ProductInterface
623
    {
624
        if (!$this->productRelations->contains($productRelation)) {
625
            $this->productRelations->add($productRelation);
626
        }
627
628
        return $this;
629 3
    }
630
631 3
    public function addSegment(SegmentInterface $segment) : ProductInterface
632 3
    {
633
        if (!$this->segments->contains($segment)) {
634
            $this->segments->add($segment);
635
        }
636
637
        return $this;
638
    }
639
640
    public function addVariant(VariantInterface $variant) : ProductInterface
641
    {
642
        if (!$this->variants->contains($variant)) {
643
            $this->variants->add($variant);
644
        }
645
646
        return $this;
647
    }
648
649
    public function addChild(ProductInterface $product) : ProductInterface
650
    {
651
        if (!$this->hasChild($product)) {
652
            $this->children->add($product);
653
            $product->setParent($this);
654
        }
655
656 3
        return $this;
657
    }
658 3
659
    public function removeChild(ProductInterface $product) : bool
660
    {
661
        $product->setParent(null);
662
        return $this->children->removeElement($product);
663
    }
664
665 3
    public function hasChild($product) : bool
666
    {
667 3
        if ($product instanceof ProductInterface) {
668 3
            $product = $product->getExternalId();
669
        }
670
671
        return $this->children->exists(function ($key, ProductInterface $element) use ($product) {
672
            return $element->getExternalId() === $product;
673
        });
674 3
    }
675
676 3
    /*
677
     * Getters / Setters
678
     */
679
    /**
680
     * @return int
681
     */
682
    public function getId(): int
683 3
    {
684
        return (int)$this->id;
685 3
    }
686 3
687
    /**
688
     * @param int $id
689
     * @return ProductInterface
690
     */
691
    public function setId(int $id)
692 3
    {
693
        $this->id = $id;
694 3
        return $this;
695
    }
696
697
    /**
698
     * @return int
699
     */
700
    public function getExternalId(): int
701 3
    {
702
        return (int)$this->externalId;
703 3
    }
704 3
705
    /**
706
     * @param int $externalId
707
     * @return ProductInterface
708
     */
709
    public function setExternalId(int $externalId)
710 3
    {
711
        $this->externalId = $externalId;
712 3
        return $this;
713
    }
714
715
    /**
716
     * @return null|string
717
     */
718
    public function getBarCodeNumber()
719 3
    {
720
        return $this->barCodeNumber;
721 3
    }
722 3
723
    /**
724
     * @param null|string $barCodeNumber
725
     * @return ProductInterface
726
     */
727
    public function setBarCodeNumber($barCodeNumber)
728 3
    {
729
        $this->barCodeNumber = $barCodeNumber;
730 3
        return $this;
731
    }
732
733
    /**
734
     * @return array|null
735
     */
736
    public function getCategoryIdList()
737 3
    {
738
        return $this->categoryIdList;
739 3
    }
740 3
741
    /**
742
     * @param array|null $categoryIdList
743
     * @return ProductInterface
744
     */
745
    public function setCategoryIdList($categoryIdList)
746
    {
747
        $this->categoryIdList = $categoryIdList;
748
        return $this;
749
    }
750
751
    /**
752
     * @return null|string
753
     */
754
    public function getComments()
755
    {
756
        return $this->comments;
757
    }
758
759
    /**
760
     * @param null|string $comments
761
     * @return ProductInterface
762
     */
763
    public function setComments($comments)
764 3
    {
765
        $this->comments = $comments;
766 3
        return $this;
767
    }
768
769
    /**
770
     * @return float|null
771
     */
772
    public function getCostPrice()
773 3
    {
774
        return $this->costPrice;
775 3
    }
776 3
777
    /**
778
     * @param float|null $costPrice
779
     * @return ProductInterface
780
     */
781
    public function setCostPrice($costPrice)
782 3
    {
783
        $this->costPrice = $costPrice;
784 3
        return $this;
785
    }
786
787
    /**
788
     * @return \DateTimeImmutable|null
789
     */
790
    public function getCreated()
791 3
    {
792
        return $this->created;
793 3
    }
794 3
795
    /**
796
     * @param \DateTimeImmutable|null $created
797
     * @return ProductInterface
798
     */
799
    public function setCreated($created)
800 3
    {
801
        $this->created = $created;
802 3
        return $this;
803
    }
804
805
    /**
806
     * @return null|string
807
     */
808
    public function getCreatedBy()
809 3
    {
810
        return $this->createdBy;
811 3
    }
812 3
813
    /**
814
     * @param null|string $createdBy
815
     * @return ProductInterface
816
     */
817
    public function setCreatedBy($createdBy)
818 3
    {
819
        $this->createdBy = $createdBy;
820 3
        return $this;
821
    }
822
823
    /**
824
     * @return int|null
825
     */
826
    public function getDefaultCategoryId()
827 3
    {
828
        return $this->defaultCategoryId;
829 3
    }
830 3
831
    /**
832
     * @param int|null $defaultCategoryId
833
     * @return ProductInterface
834
     */
835
    public function setDefaultCategoryId($defaultCategoryId)
836 3
    {
837
        $this->defaultCategoryId = $defaultCategoryId;
838 3
        return $this;
839
    }
840
841
    /**
842
     * @return array|null
843
     */
844
    public function getDisabledVariantIdList()
845 3
    {
846
        return $this->disabledVariantIdList;
847 3
    }
848 3
849
    /**
850
     * @param array|null $disabledVariantIdList
851
     * @return ProductInterface
852
     */
853
    public function setDisabledVariantIdList($disabledVariantIdList)
854 3
    {
855
        $this->disabledVariantIdList = $disabledVariantIdList;
856 3
        return $this;
857
    }
858
859
    /**
860
     * @return null|string
861
     */
862
    public function getEdbPriserProductNumber()
863 3
    {
864
        return $this->edbPriserProductNumber;
865 3
    }
866 3
867
    /**
868
     * @param null|string $edbPriserProductNumber
869
     * @return ProductInterface
870
     */
871
    public function setEdbPriserProductNumber($edbPriserProductNumber)
872 3
    {
873
        $this->edbPriserProductNumber = $edbPriserProductNumber;
874 3
        return $this;
875
    }
876
877
    /**
878
     * @return null|string
879
     */
880
    public function getFileSaleLink()
881 3
    {
882
        return $this->fileSaleLink;
883 3
    }
884 3
885
    /**
886
     * @param null|string $fileSaleLink
887
     * @return ProductInterface
888
     */
889
    public function setFileSaleLink($fileSaleLink)
890 3
    {
891
        $this->fileSaleLink = $fileSaleLink;
892 3
        return $this;
893
    }
894
895
    /**
896
     * @return null|string
897
     */
898
    public function getGoogleFeedCategory()
899 3
    {
900
        return $this->googleFeedCategory;
901 3
    }
902 3
903
    /**
904
     * @param null|string $googleFeedCategory
905
     * @return ProductInterface
906
     */
907
    public function setGoogleFeedCategory($googleFeedCategory)
908 3
    {
909
        $this->googleFeedCategory = $googleFeedCategory;
910 3
        return $this;
911
    }
912
913
    /**
914
     * @return bool|null
915
     */
916
    public function getIsGiftCertificate()
917 3
    {
918
        return $this->isGiftCertificate;
919 3
    }
920 3
921
    /**
922
     * @param bool|null $isGiftCertificate
923
     * @return ProductInterface
924
     */
925
    public function setIsGiftCertificate($isGiftCertificate)
926
    {
927
        $this->isGiftCertificate = $isGiftCertificate;
928
        return $this;
929
    }
930
931
    /**
932
     * @return bool|null
933
     */
934
    public function getIsModified()
935
    {
936
        return $this->isModified;
937
    }
938
939
    /**
940
     * @param bool|null $isModified
941
     * @return ProductInterface
942
     */
943
    public function setIsModified($isModified)
944 3
    {
945
        $this->isModified = $isModified;
946 3
        return $this;
947
    }
948
949
    /**
950
     * @return bool|null
951
     */
952
    public function getIsRateVariants()
953 3
    {
954
        return $this->isRateVariants;
955 3
    }
956 3
957
    /**
958
     * @param bool|null $isRateVariants
959
     * @return ProductInterface
960
     */
961
    public function setIsRateVariants($isRateVariants)
962 3
    {
963
        $this->isRateVariants = $isRateVariants;
964 3
        return $this;
965
    }
966
967
    /**
968
     * @return bool|null
969
     */
970
    public function getIsReviewVariants()
971 3
    {
972
        return $this->isReviewVariants;
973 3
    }
974 3
975
    /**
976
     * @param bool|null $isReviewVariants
977
     * @return ProductInterface
978
     */
979
    public function setIsReviewVariants($isReviewVariants)
980 3
    {
981
        $this->isReviewVariants = $isReviewVariants;
982 3
        return $this;
983
    }
984
985
    /**
986
     * @return bool|null
987
     */
988
    public function getIsVariantMaster()
989 3
    {
990
        return $this->isVariantMaster;
991 3
    }
992 3
993
    /**
994
     * @param bool|null $isVariantMaster
995
     * @return ProductInterface
996
     */
997
    public function setIsVariantMaster($isVariantMaster)
998 3
    {
999
        $this->isVariantMaster = $isVariantMaster;
1000 3
        return $this;
1001
    }
1002
1003
    /**
1004
     * @return null|string
1005
     */
1006
    public function getLocationNumber()
1007 3
    {
1008
        return $this->locationNumber;
1009 3
    }
1010 3
1011
    /**
1012
     * @param null|string $locationNumber
1013
     * @return ProductInterface
1014
     */
1015
    public function setLocationNumber($locationNumber)
1016 3
    {
1017
        $this->locationNumber = $locationNumber;
1018 3
        return $this;
1019
    }
1020
1021
    /**
1022
     * @return array|null
1023
     */
1024
    public function getManufacturereIdList()
1025 3
    {
1026
        return $this->manufacturereIdList;
1027 3
    }
1028 3
1029
    /**
1030
     * @param array|null $manufacturereIdList
1031
     * @return ProductInterface
1032
     */
1033
    public function setManufacturereIdList($manufacturereIdList)
1034 3
    {
1035
        $this->manufacturereIdList = $manufacturereIdList;
1036 3
        return $this;
1037
    }
1038
1039
    /**
1040
     * @return int|null
1041
     */
1042
    public function getMaxBuyAmount()
1043 3
    {
1044
        return $this->maxBuyAmount;
1045 3
    }
1046 3
1047
    /**
1048
     * @param int|null $maxBuyAmount
1049
     * @return ProductInterface
1050
     */
1051
    public function setMaxBuyAmount($maxBuyAmount)
1052
    {
1053
        $this->maxBuyAmount = $maxBuyAmount;
1054
        return $this;
1055
    }
1056
1057
    /**
1058
     * @return int|null
1059
     */
1060
    public function getMinBuyAmount()
1061
    {
1062
        return $this->minBuyAmount;
1063
    }
1064
1065
    /**
1066
     * @param int|null $minBuyAmount
1067
     * @return ProductInterface
1068
     */
1069
    public function setMinBuyAmount($minBuyAmount)
1070 3
    {
1071
        $this->minBuyAmount = $minBuyAmount;
1072 3
        return $this;
1073
    }
1074
1075
    /**
1076
     * @return int|null
1077
     */
1078
    public function getMinBuyAmountB2B()
1079 3
    {
1080
        return $this->minBuyAmountB2B;
1081 3
    }
1082 3
1083
    /**
1084
     * @param int|null $minBuyAmountB2B
1085
     * @return ProductInterface
1086
     */
1087
    public function setMinBuyAmountB2B($minBuyAmountB2B)
1088 3
    {
1089
        $this->minBuyAmountB2B = $minBuyAmountB2B;
1090 3
        return $this;
1091
    }
1092
1093
    /**
1094
     * @return string
1095
     */
1096
    public function getNumber()
1097 3
    {
1098
        return (string)$this->number;
1099 3
    }
1100 3
1101
    /**
1102
     * @param string $number
1103
     * @return ProductInterface
1104
     */
1105
    public function setNumber(string $number)
1106 3
    {
1107
        $this->number = $number;
1108 3
        return $this;
1109
    }
1110
1111
    /**
1112
     * @return null|string
1113
     */
1114
    public function getPicture()
1115 3
    {
1116
        return $this->picture;
1117 3
    }
1118 3
1119
    /**
1120
     * @param null|string $picture
1121
     * @return ProductInterface
1122
     */
1123
    public function setPicture($picture)
1124 3
    {
1125
        $this->picture = $picture;
1126 3
        return $this;
1127
    }
1128
1129
    /**
1130
     * @return int|null
1131
     */
1132
    public function getSalesCount()
1133 3
    {
1134
        return $this->salesCount;
1135 3
    }
1136 3
1137
    /**
1138
     * @param int|null $salesCount
1139
     * @return ProductInterface
1140
     */
1141
    public function setSalesCount($salesCount)
1142 3
    {
1143
        $this->salesCount = $salesCount;
1144 3
        return $this;
1145
    }
1146
1147
    /**
1148
     * @return array|null
1149
     */
1150
    public function getSegmentIdList()
1151 3
    {
1152
        return $this->segmentIdList;
1153 3
    }
1154 3
1155
    /**
1156
     * @param array|null $segmentIdList
1157
     * @return ProductInterface
1158
     */
1159
    public function setSegmentIdList($segmentIdList)
1160 3
    {
1161
        $this->segmentIdList = $segmentIdList;
1162 3
        return $this;
1163
    }
1164
1165
    /**
1166
     * @return int|null
1167
     */
1168
    public function getSortOrder()
1169 3
    {
1170
        return $this->sortOrder;
1171 3
    }
1172 3
1173
    /**
1174
     * @param int|null $sortOrder
1175
     * @return ProductInterface
1176
     */
1177
    public function setSortOrder($sortOrder)
1178
    {
1179
        $this->sortOrder = $sortOrder;
1180
        return $this;
1181
    }
1182
1183
    /**
1184
     * @return int|null
1185
     */
1186
    public function getStockCount()
1187
    {
1188
        return $this->stockCount;
1189
    }
1190
1191
    /**
1192
     * @param int|null $stockCount
1193
     * @return ProductInterface
1194
     */
1195
    public function setStockCount($stockCount)
1196
    {
1197
        $this->stockCount = $stockCount;
1198
        return $this;
1199
    }
1200
1201
    /**
1202
     * @return int|null
1203
     */
1204
    public function getStockLimit()
1205
    {
1206
        return $this->stockLimit;
1207
    }
1208
1209
    /**
1210
     * @param int|null $stockLimit
1211
     * @return ProductInterface
1212
     */
1213
    public function setStockLimit($stockLimit)
1214 3
    {
1215
        $this->stockLimit = $stockLimit;
1216 3
        return $this;
1217
    }
1218
1219
    /**
1220
     * @return int|null
1221
     */
1222
    public function getTypeId()
1223 3
    {
1224
        return $this->typeId;
1225 3
    }
1226 3
1227
    /**
1228
     * @param int|null $typeId
1229
     * @return ProductInterface
1230
     */
1231
    public function setTypeId($typeId)
1232 3
    {
1233
        $this->typeId = $typeId;
1234 3
        return $this;
1235
    }
1236
1237
    /**
1238
     * @return \DateTimeImmutable|null
1239
     */
1240
    public function getUpdated()
1241 3
    {
1242
        return $this->updated;
1243 3
    }
1244 3
1245
    /**
1246
     * @param \DateTimeImmutable|null $updated
1247
     * @return ProductInterface
1248
     */
1249
    public function setUpdated($updated)
1250 3
    {
1251
        $this->updated = $updated;
1252 3
        return $this;
1253
    }
1254
1255
    /**
1256
     * @return null|string
1257
     */
1258
    public function getUpdatedBy()
1259 3
    {
1260
        return $this->updatedBy;
1261 3
    }
1262 3
1263
    /**
1264
     * @param null|string $updatedBy
1265
     * @return ProductInterface
1266
     */
1267
    public function setUpdatedBy($updatedBy)
1268
    {
1269
        $this->updatedBy = $updatedBy;
1270
        return $this;
1271
    }
1272
1273
    /**
1274
     * @return array|null
1275
     */
1276
    public function getVariantGroupIdList()
1277
    {
1278
        return $this->variantGroupIdList;
1279
    }
1280
1281
    /**
1282
     * @param array|null $variantGroupIdList
1283
     * @return ProductInterface
1284
     */
1285
    public function setVariantGroupIdList($variantGroupIdList)
1286
    {
1287
        $this->variantGroupIdList = $variantGroupIdList;
1288
        return $this;
1289
    }
1290
1291
    /**
1292
     * @return array|null
1293
     */
1294
    public function getVariantIdList()
1295
    {
1296
        return $this->variantIdList;
1297
    }
1298
1299
    /**
1300
     * @param array|null $variantIdList
1301
     * @return ProductInterface
1302
     */
1303
    public function setVariantIdList($variantIdList)
1304
    {
1305
        $this->variantIdList = $variantIdList;
1306
        return $this;
1307
    }
1308
1309
    /**
1310
     * @return int|null
1311
     */
1312
    public function getVariantMasterId()
1313
    {
1314
        return $this->variantMasterId;
1315
    }
1316
1317
    /**
1318
     * @param int|null $variantMasterId
1319
     * @return ProductInterface
1320
     */
1321
    public function setVariantMasterId($variantMasterId)
1322
    {
1323
        $this->variantMasterId = $variantMasterId;
1324
        return $this;
1325
    }
1326
1327
    /**
1328
     * @return null|string
1329
     */
1330
    public function getVendorNumber()
1331
    {
1332
        return $this->vendorNumber;
1333
    }
1334
1335
    /**
1336
     * @param null|string $vendorNumber
1337
     * @return ProductInterface
1338
     */
1339
    public function setVendorNumber($vendorNumber)
1340
    {
1341
        $this->vendorNumber = $vendorNumber;
1342
        return $this;
1343
    }
1344
1345
    /**
1346
     * @return int|null
1347
     */
1348
    public function getWeight()
1349
    {
1350
        return $this->weight;
1351
    }
1352
1353
    /**
1354
     * @param int|null $weight
1355
     * @return ProductInterface
1356
     */
1357
    public function setWeight($weight)
1358
    {
1359
        $this->weight = $weight;
1360
        return $this;
1361
    }
1362
1363
    /**
1364
     * @return ArrayCollection|Category[]
1365
     */
1366
    public function getCategories()
1367
    {
1368
        return $this->categories;
1369
    }
1370
1371
    /**
1372
     * @param ArrayCollection|Category[] $categories
1373
     * @return ProductInterface
1374
     */
1375
    public function setCategories($categories)
1376
    {
1377
        $this->categories = $categories;
1378
        return $this;
1379
    }
1380
1381
    /**
1382
     * @return ArrayCollection|Variant[]
1383
     */
1384
    public function getDisabledVariants()
1385
    {
1386
        return $this->disabledVariants;
1387
    }
1388
1389
    /**
1390
     * @param ArrayCollection|Variant[] $disabledVariants
1391
     * @return ProductInterface
1392
     */
1393
    public function setDisabledVariants($disabledVariants)
1394
    {
1395
        $this->disabledVariants = $disabledVariants;
1396
        return $this;
1397
    }
1398
1399
    /**
1400
     * @return ArrayCollection|Manufacturer[]
1401
     */
1402
    public function getManufacturers()
1403
    {
1404
        return $this->manufacturers;
1405
    }
1406
1407
    /**
1408
     * @param ArrayCollection|Manufacturer[] $manufacturers
1409
     * @return ProductInterface
1410
     */
1411
    public function setManufacturers($manufacturers)
1412
    {
1413
        $this->manufacturers = $manufacturers;
1414
        return $this;
1415
    }
1416
1417
    /**
1418
     * @return ArrayCollection|Medium[]
1419
     */
1420
    public function getMedia()
1421
    {
1422
        return $this->media;
1423
    }
1424
1425
    /**
1426
     * @param ArrayCollection|Medium[] $media
1427
     * @return ProductInterface
1428
     */
1429
    public function setMedia($media)
1430
    {
1431
        $this->media = $media;
1432
        return $this;
1433
    }
1434
1435
    /**
1436
     * @return bool
1437
     */
1438
    public function isPriceLess(): bool
1439
    {
1440
        return $this->priceLess;
1441
    }
1442
1443
    /**
1444
     * @param bool $priceLess
1445
     * @return Product
1446
     */
1447
    public function setPriceLess(bool $priceLess)
1448
    {
1449
        $this->priceLess = $priceLess;
1450
        return $this;
1451
    }
1452
1453
    /**
1454
     * @return ArrayCollection|Price[]
1455
     */
1456
    public function getPrices()
1457
    {
1458
        return $this->prices;
1459
    }
1460
1461
    /**
1462
     * @param ArrayCollection|Price[] $prices
1463
     * @return ProductInterface
1464
     */
1465
    public function setPrices($prices)
1466
    {
1467
        $this->prices = $prices;
1468
        return $this;
1469
    }
1470
1471
    /**
1472
     * @return ArrayCollection|ProductRelation[]
1473
     */
1474
    public function getProductRelations()
1475
    {
1476
        return $this->productRelations;
1477
    }
1478
1479
    /**
1480
     * @param ArrayCollection|ProductRelation[] $productRelations
1481
     * @return ProductInterface
1482
     */
1483
    public function setProductRelations($productRelations)
1484
    {
1485
        $this->productRelations = $productRelations;
1486
        return $this;
1487
    }
1488
1489
    /**
1490
     * @return ProductTypeInterface
1491
     */
1492
    public function getProductType(): ProductTypeInterface
1493
    {
1494
        return $this->productType;
1495
    }
1496
1497
    /**
1498
     * @param ProductType $productType
1499
     * @return ProductInterface
1500
     */
1501
    public function setProductType(ProductType $productType)
1502
    {
1503
        $this->productType = $productType;
1504
        return $this;
1505
    }
1506
1507
    /**
1508
     * @return ArrayCollection|Segment[]
1509
     */
1510
    public function getSegments()
1511
    {
1512
        return $this->segments;
1513
    }
1514
1515
    /**
1516
     * @param ArrayCollection|Segment[] $segments
1517
     * @return ProductInterface
1518
     */
1519
    public function setSegments($segments)
1520
    {
1521
        $this->segments = $segments;
1522
        return $this;
1523
    }
1524
1525
    /**
1526
     * @return ArrayCollection|VariantGroup[]
1527
     */
1528
    public function getVariantGroups()
1529
    {
1530
        return $this->variantGroups;
1531
    }
1532
1533
    /**
1534
     * @param ArrayCollection|VariantGroup[] $variantGroups
1535
     * @return ProductInterface
1536
     */
1537
    public function setVariantGroups($variantGroups)
1538
    {
1539
        $this->variantGroups = $variantGroups;
1540
        return $this;
1541
    }
1542
1543
    /**
1544
     * @return ArrayCollection|Variant[]
1545
     */
1546
    public function getVariants()
1547
    {
1548
        return $this->variants;
1549
    }
1550
1551
    /**
1552
     * @param ArrayCollection|Variant[] $variants
1553
     * @return ProductInterface
1554
     */
1555
    public function setVariants($variants)
1556
    {
1557
        $this->variants = $variants;
1558
        return $this;
1559
    }
1560
1561
    /**
1562
     * @return Product|null
1563
     */
1564
    public function getParent(): ?Product
1565
    {
1566
        return $this->parent;
1567
    }
1568
1569
    /**
1570
     * @param Product|null $parent
1571
     * @return Product
1572
     */
1573
    public function setParent(?Product $parent)
1574
    {
1575
        $this->parent = $parent;
1576
        return $this;
1577
    }
1578
1579
    /**
1580
     * @return ArrayCollection|Product[]
1581
     */
1582
    public function getChildren()
1583
    {
1584
        return $this->children;
1585
    }
1586
1587
    /**
1588
     * @param ArrayCollection|Product[] $children
1589
     * @return Product
1590
     */
1591
    public function setChildren($children)
1592
    {
1593
        $this->children = $children;
1594
        return $this;
1595
    }
1596
}
1597