Passed
Push — master ( 0e978b...2ba142 )
by Aimeos
05:41
created

Standard::setQuantityOpen()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 3
nc 2
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @license LGPLv3, https://opensource.org/licenses/LGPL-3.0
5
 * @copyright Metaways Infosystems GmbH, 2011
6
 * @copyright Aimeos (aimeos.org), 2015-2021
7
 * @package MShop
8
 * @subpackage Order
9
 */
10
11
12
namespace Aimeos\MShop\Order\Item\Base\Product;
13
14
15
/**
16
 * Product item of order base
17
 * @package MShop
18
 * @subpackage Order
19
 */
20
class Standard extends Base implements Iface
21
{
22
	/**
23
	 * Initializes the order product instance.
24
	 *
25
	 * @param \Aimeos\MShop\Price\Item\Iface $price Price item
26
	 * @param array $values Associative list of order product values
27
	 * @param \Aimeos\MShop\Order\Item\Base\Product\Attribute\Iface[] $attributes List of order product attribute items
28
	 * @param \Aimeos\MShop\Order\Item\Base\Product\Iface[] $products List of ordered subproduct items
29
	 */
30
	public function __construct( \Aimeos\MShop\Price\Item\Iface $price, array $values = [], array $attributes = [], array $products = [] )
31
	{
32
		parent::__construct( $price, $values, $attributes, $products );
33
	}
34
35
36
	/**
37
	 * Returns the associated product item
38
	 *
39
	 * @return \Aimeos\MShop\Product\Item\Iface|null Product item
40
	 */
41
	public function getProductItem() : ?\Aimeos\MShop\Product\Item\Iface
42
	{
43
		return $this->get( '.product' );
44
	}
45
46
47
	/**
48
	 * Returns the associated supplier item
49
	 *
50
	 * @return \Aimeos\MShop\Supplier\Item\Iface|null Supplier item
51
	 */
52
	public function getSupplierItem() : ?\Aimeos\MShop\Supplier\Item\Iface
53
	{
54
		return $this->get( '.supplier' );
55
	}
56
57
58
	/**
59
	 * Returns the ID of the site the item is stored
60
	 *
61
	 * @return string Site ID (or null if not available)
62
	 */
63
	public function getSiteId() : string
64
	{
65
		return $this->get( 'order.base.product.siteid', '' );
66
	}
67
68
69
	/**
70
	 * Sets the site ID of the item.
71
	 *
72
	 * @param string $value Unique site ID of the item
73
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order base product item for chaining method calls
74
	 */
75
	public function setSiteId( string $value ) : \Aimeos\MShop\Order\Item\Base\Product\Iface
76
	{
77
		return $this->set( 'order.base.product.siteid', $value );
78
	}
79
80
81
	/**
82
	 * Returns the base ID.
83
	 *
84
	 * @return string|null Base ID
85
	 */
86
	public function getBaseId() : ?string
87
	{
88
		return $this->get( 'order.base.product.baseid' );
89
	}
90
91
92
	/**
93
	 * Sets the base order ID the product belongs to.
94
	 *
95
	 * @param string|null $value New order base ID
96
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order base product item for chaining method calls
97
	 */
98
	public function setBaseId( ?string $value ) : \Aimeos\MShop\Order\Item\Base\Product\Iface
99
	{
100
		return $this->set( 'order.base.product.baseid', $value );
101
	}
102
103
104
	/**
105
	 * Returns the order address ID the product should be shipped to
106
	 *
107
	 * @return string|null Order address ID
108
	 */
109
	public function getOrderAddressId() : ?string
110
	{
111
		return $this->get( 'order.base.product.orderaddressid' );
112
	}
113
114
115
	/**
116
	 * Sets the order address ID the product should be shipped to
117
	 *
118
	 * @param string|null $value Order address ID
119
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order base product item for chaining method calls
120
	 */
121
	public function setOrderAddressId( ?string $value ) : \Aimeos\MShop\Order\Item\Base\Product\Iface
122
	{
123
		return $this->set( 'order.base.product.orderaddressid', ( $value !== null ? $value : null ) );
124
	}
125
126
127
	/**
128
	 * Returns the parent ID of the ordered product if there is one.
129
	 * This ID relates to another product of the same order and provides a relation for e.g. sub-products in bundles.
130
	 *
131
	 * @return string|null Order product ID
132
	 */
133
	public function getOrderProductId() : ?string
134
	{
135
		return $this->get( 'order.base.product.orderproductid' );
136
	}
137
138
139
	/**
140
	 * Sets the parent ID of the ordered product.
141
	 * This ID relates to another product of the same order and provides a relation for e.g. sub-products in bundles.
142
	 *
143
	 * @param string|null $value Order product ID
144
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order base product item for chaining method calls
145
	 */
146
	public function setOrderProductId( ?string $value ) : \Aimeos\MShop\Order\Item\Base\Product\Iface
147
	{
148
		return $this->set( 'order.base.product.orderproductid', ( $value !== null ? $value : null ) );
149
	}
150
151
152
	/**
153
	 * Returns the type of the ordered product.
154
	 *
155
	 * @return string Type of the ordered product
156
	 */
157
	public function getType() : string
158
	{
159
		return $this->get( 'order.base.product.type', '' );
160
	}
161
162
163
	/**
164
	 * Sets the type of the ordered product.
165
	 *
166
	 * @param string $type Type of the order product
167
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order base product item for chaining method calls
168
	 */
169
	public function setType( string $type ) : \Aimeos\MShop\Common\Item\Iface
170
	{
171
		return $this->set( 'order.base.product.type', $this->checkCode( $type ) );
172
	}
173
174
175
	/**
176
	 * Returns the supplier ID.
177
	 *
178
	 * @return string The ID of the supplier
179
	 */
180
	public function getSupplierId() : string
181
	{
182
		return $this->get( 'order.base.product.supplierid', '' );
183
	}
184
185
186
	/**
187
	 * Sets the supplier ID.
188
	 *
189
	 * @param string|null $value ID of the supplier
190
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order base product item for chaining method calls
191
	 */
192
	public function setSupplierId( ?string $value ) : \Aimeos\MShop\Order\Item\Base\Product\Iface
193
	{
194
		return $this->set( 'order.base.product.supplierid', (string) $value );
195
	}
196
197
198
	/**
199
	 * Returns the supplier name.
200
	 *
201
	 * @return string Supplier name
202
	 */
203
	public function getSupplierName() : string
204
	{
205
		return $this->get( 'order.base.product.suppliername', '' );
206
	}
207
208
209
	/**
210
	 * Sets the supplier name.
211
	 *
212
	 * @param string|null $value Supplier name
213
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order base product item for chaining method calls
214
	 */
215
	public function setSupplierName( ?string $value ) : \Aimeos\MShop\Order\Item\Base\Product\Iface
216
	{
217
		return $this->set( 'order.base.product.suppliername', (string) $value );
218
	}
219
220
221
	/**
222
	 * Returns the product ID the customer has selected.
223
	 *
224
	 * @return string Original product ID
225
	 */
226
	public function getProductId() : string
227
	{
228
		return $this->get( 'order.base.product.productid', '' );
229
	}
230
231
232
	/**
233
	 * Sets the ID of a product the customer has selected.
234
	 *
235
	 * @param string $id Product Code ID
236
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order base product item for chaining method calls
237
	 */
238
	public function setProductId( ?string $id ) : \Aimeos\MShop\Order\Item\Base\Product\Iface
239
	{
240
		return $this->set( 'order.base.product.productid', (string) $id );
241
	}
242
243
244
	/**
245
	 * Returns the product code the customer has selected.
246
	 *
247
	 * @return string Product code
248
	 */
249
	public function getProductCode() : string
250
	{
251
		return $this->get( 'order.base.product.prodcode', '' );
252
	}
253
254
255
	/**
256
	 * Sets the code of a product the customer has selected.
257
	 *
258
	 * @param string $code Product code
259
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order base product item for chaining method calls
260
	 */
261
	public function setProductCode( string $code ) : \Aimeos\MShop\Order\Item\Base\Product\Iface
262
	{
263
		return $this->set( 'order.base.product.prodcode', $this->checkCode( $code ) );
264
	}
265
266
267
	/**
268
	 * Returns the code of the stock type the product should be retrieved from.
269
	 *
270
	 * @return string Stock type
271
	 */
272
	public function getStockType() : string
273
	{
274
		return $this->get( 'order.base.product.stocktype', '' );
275
	}
276
277
278
	/**
279
	 * Sets the code of the stock type the product should be retrieved from.
280
	 *
281
	 * @param string $code Stock type
282
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order base product item for chaining method calls
283
	 */
284
	public function setStockType( string $code ) : \Aimeos\MShop\Order\Item\Base\Product\Iface
285
	{
286
		return $this->set( 'order.base.product.stocktype', $this->checkCode( $code ) );
287
	}
288
289
290
	/**
291
	 * Returns the localized name of the product.
292
	 *
293
	 * @return string Returns the localized name of the product
294
	 */
295
	public function getName() : string
296
	{
297
		return $this->get( 'order.base.product.name', '' );
298
	}
299
300
301
	/**
302
	 * Sets the localized name of the product.
303
	 *
304
	 * @param string $value Localized name of the product
305
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order base product item for chaining method calls
306
	 */
307
	public function setName( string $value ) : \Aimeos\MShop\Order\Item\Base\Product\Iface
308
	{
309
		return $this->set( 'order.base.product.name', $value );
310
	}
311
312
313
	/**
314
	 * Returns the localized description of the product.
315
	 *
316
	 * @return string Returns the localized description of the product
317
	 */
318
	public function getDescription() : string
319
	{
320
		return $this->get( 'order.base.product.description', '' );
321
	}
322
323
324
	/**
325
	 * Sets the localized description of the product.
326
	 *
327
	 * @param string $value Localized description of the product
328
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order base product item for chaining method calls
329
	 */
330
	public function setDescription( string $value ) : \Aimeos\MShop\Order\Item\Base\Product\Iface
331
	{
332
		return $this->set( 'order.base.product.description', $value );
333
	}
334
335
336
	/**
337
	 * Returns the location of the media.
338
	 *
339
	 * @return string Location of the media
340
	 */
341
	public function getMediaUrl() : string
342
	{
343
		return $this->get( 'order.base.product.mediaurl', '' );
344
	}
345
346
347
	/**
348
	 * Sets the media url of the product the customer has added.
349
	 *
350
	 * @param string $value Location of the media/picture
351
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order base product item for chaining method calls
352
	 */
353
	public function setMediaUrl( string $value ) : \Aimeos\MShop\Order\Item\Base\Product\Iface
354
	{
355
		return $this->set( 'order.base.product.mediaurl', $value );
356
	}
357
358
359
	/**
360
	 * Returns the URL target specific for that product
361
	 *
362
	 * @return string URL target specific for that product
363
	 */
364
	public function getTarget() : string
365
	{
366
		return $this->get( 'order.base.product.target', '' );
367
	}
368
369
370
	/**
371
	 * Sets the URL target specific for that product
372
	 *
373
	 * @param string $value New URL target specific for that product
374
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order base product item for chaining method calls
375
	 */
376
	public function setTarget( string $value ) : \Aimeos\MShop\Order\Item\Base\Product\Iface
377
	{
378
		return $this->set( 'order.base.product.target', $value );
379
	}
380
381
382
	/**
383
	 * Returns the expected delivery time frame
384
	 *
385
	 * @return string Expected delivery time frame
386
	 */
387
	public function getTimeframe() : string
388
	{
389
		return $this->get( 'order.base.product.timeframe', '' );
390
	}
391
392
393
	/**
394
	 * Sets the expected delivery time frame
395
	 *
396
	 * @param string $timeframe Expected delivery time frame
397
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order base product item for chaining method calls
398
	 */
399
	public function setTimeframe( string $timeframe ) : \Aimeos\MShop\Order\Item\Base\Product\Iface
400
	{
401
		return $this->set( 'order.base.product.timeframe', $timeframe );
402
	}
403
404
405
	/**
406
	 * Returns the amount of products the customer has added.
407
	 *
408
	 * @return float Amount of products
409
	 */
410
	public function getQuantity() : float
411
	{
412
		return (float) $this->get( 'order.base.product.quantity', 1 );
413
	}
414
415
416
	/**
417
	 * Sets the amount of products the customer has added.
418
	 *
419
	 * @param float $quantity Amount of products
420
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order base product item for chaining method calls
421
	 */
422
	public function setQuantity( float $quantity ) : \Aimeos\MShop\Order\Item\Base\Product\Iface
423
	{
424
		if( $quantity <= 0 || $quantity > 2147483647 ) {
425
			throw new \Aimeos\MShop\Order\Exception( sprintf( 'Quantity must be greater than 0 and must not exceed %1$d', 2147483647 ) );
426
		}
427
428
		return $this->set( 'order.base.product.quantity', $quantity );
429
	}
430
431
432
	/**
433
	 * Returns the number of packages not yet delivered to the customer.
434
	 *
435
	 * @return float Amount of product packages
436
	 */
437
	public function getQuantityOpen() : float
438
	{
439
		return (float) $this->get( 'order.base.product.qtyopen', 0 );
440
	}
441
442
443
	/**
444
	 * Sets the number of product packages not yet delivered to the customer.
445
	 *
446
	 * @param float $quantity Amount of product packages
447
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order base product item for chaining method calls
448
	 */
449
	public function setQuantityOpen( float $quantity ) : \Aimeos\MShop\Order\Item\Base\Product\Iface
450
	{
451
		if( $quantity < 0 || $quantity > $this->getQuantity() ) {
452
			throw new \Aimeos\MShop\Order\Exception( sprintf( 'Quantity must be 0 or greater and must not exceed %1$d', $this->getQuantity() ) );
453
		}
454
455
		return $this->set( 'order.base.product.qtyopen', $quantity );
456
	}
457
458
459
	/**
460
	 * 	Returns the flags for the product item.
461
	 *
462
	 * @return int Flags, e.g. for immutable products
463
	 */
464
	public function getFlags() : int
465
	{
466
		return $this->get( 'order.base.product.flags', \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_NONE );
467
	}
468
469
470
	/**
471
	 * Sets the new value for the product item flags.
472
	 *
473
	 * @param int $value Flags, e.g. for immutable products
474
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order base product item for chaining method calls
475
	 */
476
	public function setFlags( int $value ) : \Aimeos\MShop\Order\Item\Base\Product\Iface
477
	{
478
		return $this->set( 'order.base.product.flags', $this->checkFlags( $value ) );
479
	}
480
481
482
	/**
483
	 * Returns the position of the product in the order.
484
	 *
485
	 * @return int|null Product position in the order from 0-n
486
	 */
487
	public function getPosition() : ?int
488
	{
489
		return $this->get( 'order.base.product.position' );
490
	}
491
492
493
	/**
494
	 * Sets the position of the product within the list of ordered products.
495
	 *
496
	 * @param int|null $value Product position in the order from 0-n or null for resetting the position
497
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order base product item for chaining method calls
498
	 * @throws \Aimeos\MShop\Order\Exception If the position is invalid
499
	 */
500
	public function setPosition( ?int $value ) : \Aimeos\MShop\Order\Item\Base\Product\Iface
501
	{
502
		if( $value < 0 ) {
503
			throw new \Aimeos\MShop\Order\Exception( sprintf( 'Order product position "%1$s" must be greater than 0', $value ) );
504
		}
505
506
		return $this->set( 'order.base.product.position', ( $value !== null ? $value : null ) );
507
	}
508
509
510
	/**
511
	 * Returns the current delivery status of the order product item.
512
	 *
513
	 * The returned status values are the STAT_* constants from the
514
	 * \Aimeos\MShop\Order\Item\Base class
515
	 *
516
	 * @return int Delivery status of the product
517
	 */
518
	public function getStatus() : int
519
	{
520
		return $this->get( 'order.base.product.status', \Aimeos\MShop\Order\Item\Base::STAT_UNFINISHED );
521
	}
522
523
524
	/**
525
	 * Sets the new delivery status of the order product item.
526
	 *
527
	 * Possible status values are the STAT_* constants from the
528
	 * \Aimeos\MShop\Order\Item\Base class
529
	 *
530
	 * @param int $value New delivery status of the product
531
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order base product item for chaining method calls
532
	 */
533
	public function setStatus( int $value ) : \Aimeos\MShop\Order\Item\Base\Product\Iface
534
	{
535
		return $this->set( 'order.base.product.status', $value );
536
	}
537
538
	/**
539
	 * Returns the notes for the ordered product.
540
	 *
541
	 * @return string Notes for the ordered product
542
	 */
543
	public function getNotes() : string
544
	{
545
		return $this->get( 'order.base.product.notes', '' );
546
	}
547
548
549
	/**
550
	 * Sets the notes for the ordered product.
551
	 *
552
	 * @param string $value Notes for the ordered product
553
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order base product item for chaining method calls
554
	 */
555
	public function setNotes( string $value ) : \Aimeos\MShop\Order\Item\Base\Product\Iface
556
	{
557
		return $this->set( 'order.base.product.notes', $value );
558
	}
559
560
561
	/*
562
	 * Sets the item values from the given array and removes that entries from the list
563
	 *
564
	 * @param array &$list Associative list of item keys and their values
565
	 * @param bool True to set private properties too, false for public only
566
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order product item for chaining method calls
567
	 */
568
	public function fromArray( array &$list, bool $private = false ) : \Aimeos\MShop\Common\Item\Iface
569
	{
570
		$item = parent::fromArray( $list, $private );
571
572
		foreach( $list as $key => $value )
573
		{
574
			switch( $key )
575
			{
576
				case 'order.base.product.siteid': !$private ?: $item = $item->setSiteId( $value ); break;
577
				case 'order.base.product.baseid': !$private ?: $item = $item->setBaseId( $value ); break;
578
				case 'order.base.product.orderproductid': !$private ?: $item = $item->setOrderProductId( $value ); break;
579
				case 'order.base.product.orderaddressid': !$private ?: $item = $item->setOrderAddressId( $value ); break;
580
				case 'order.base.product.flags': !$private ?: $item = $item->setFlags( (int) $value ); break;
581
				case 'order.base.product.type': $item = $item->setType( $value ); break;
582
				case 'order.base.product.stocktype': $item = $item->setStockType( $value ); break;
583
				case 'order.base.product.productid': $item = $item->setProductId( $value ); break;
584
				case 'order.base.product.prodcode': $item = $item->setProductCode( $value ); break;
585
				case 'order.base.product.supplierid': $item = $item->setSupplierId( $value ); break;
586
				case 'order.base.product.suppliername': $item = $item->setSupplierName( $value ); break;
587
				case 'order.base.product.name': $item = $item->setName( $value ); break;
588
				case 'order.base.product.description': $item = $item->setDescription( $value ); break;
589
				case 'order.base.product.mediaurl': $item = $item->setMediaUrl( $value ); break;
590
				case 'order.base.product.timeframe': $item = $item->setTimeFrame( $value ); break;
591
				case 'order.base.product.target': !$private ?: $item = $item->setTarget( $value ); break;
592
				case 'order.base.product.position': !$private ?: $item = $item->setPosition( (int) $value ); break;
593
				case 'order.base.product.quantity': $item = $item->setQuantity( (float) $value ); break;
594
				case 'order.base.product.qtyopen': $item = $item->setQuantityOpen( (float) $value ); break;
595
				case 'order.base.product.notes': $item = $item->setNotes( (string) $value ); break;
596
				case 'order.base.product.status': $item = $item->setStatus( (int) $value ); break;
597
				default: continue 2;
598
			}
599
600
			unset( $list[$key] );
601
		}
602
603
		return $item;
604
	}
605
606
607
	/**
608
	 * Returns the item values as associative list.
609
	 *
610
	 * @param bool True to return private properties, false for public only
611
	 * @return array Associative list of item properties and their values
612
	 */
613
	public function toArray( bool $private = false ) : array
614
	{
615
		$list = parent::toArray( $private );
616
617
		$list['order.base.product.type'] = $this->getType();
618
		$list['order.base.product.stocktype'] = $this->getStockType();
619
		$list['order.base.product.prodcode'] = $this->getProductCode();
620
		$list['order.base.product.productid'] = $this->getProductId();
621
		$list['order.base.product.supplierid'] = $this->getSupplierId();
622
		$list['order.base.product.suppliername'] = $this->getSupplierName();
623
		$list['order.base.product.qtyopen'] = $this->getQuantityOpen();
624
		$list['order.base.product.quantity'] = $this->getQuantity();
625
		$list['order.base.product.name'] = $this->getName();
626
		$list['order.base.product.description'] = $this->getDescription();
627
		$list['order.base.product.mediaurl'] = $this->getMediaUrl();
628
		$list['order.base.product.timeframe'] = $this->getTimeFrame();
629
		$list['order.base.product.position'] = $this->getPosition();
630
		$list['order.base.product.status'] = $this->getStatus();
631
		$list['order.base.product.notes'] = $this->getNotes();
632
633
		if( $private === true )
634
		{
635
			$list['order.base.product.baseid'] = $this->getBaseId();
636
			$list['order.base.product.orderproductid'] = $this->getOrderProductId();
637
			$list['order.base.product.orderaddressid'] = $this->getOrderAddressId();
638
			$list['order.base.product.target'] = $this->getTarget();
639
			$list['order.base.product.flags'] = $this->getFlags();
640
		}
641
642
		return $list;
643
	}
644
645
	/**
646
	 * Compares the properties of the given order product item with its own ones.
647
	 *
648
	 * @param \Aimeos\MShop\Order\Item\Base\Product\Iface $item Order product item
649
	 * @return bool True if the item properties are equal, false if not
650
	 * @since 2014.09
651
	 */
652
	public function compare( \Aimeos\MShop\Order\Item\Base\Product\Iface $item ) : bool
653
	{
654
		if( $this->getFlags() === $item->getFlags()
655
			&& $this->getName() === $item->getName()
656
			&& $this->getSiteId() === $item->getSiteId()
657
			&& $this->getStockType() === $item->getStockType()
658
			&& $this->getSupplierId() === $item->getSupplierId()
659
			&& $this->getProductCode() === $item->getProductCode()
660
			&& $this->getOrderAddressId() === $item->getOrderAddressId()
661
		) {
662
			return true;
663
		}
664
665
		return false;
666
	}
667
668
669
	/**
670
	 * Copys all data from a given product item.
671
	 *
672
	 * @param \Aimeos\MShop\Product\Item\Iface $product Product item to copy from
673
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order product item for chaining method calls
674
	 */
675
	public function copyFrom( \Aimeos\MShop\Product\Item\Iface $product ) : \Aimeos\MShop\Order\Item\Base\Product\Iface
676
	{
677
		$values = $product->toArray();
678
		$this->fromArray( $values );
679
680
		$this->setSiteId( $product->getSiteId() );
681
		$this->setProductCode( $product->getCode() );
682
		$this->setProductId( $product->getId() );
683
		$this->setType( $product->getType() );
0 ignored issues
show
Bug introduced by
It seems like $product->getType() can also be of type null; however, parameter $type of Aimeos\MShop\Order\Item\...uct\Standard::setType() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

683
		$this->setType( /** @scrutinizer ignore-type */ $product->getType() );
Loading history...
684
		$this->setTarget( $product->getTarget() );
685
		$this->setName( $product->getName() );
686
687
		if( ( $item = $product->getRefItems( 'text', 'basket', 'default' )->first() ) !== null ) {
688
			$this->setDescription( $item->getContent() );
689
		}
690
691
		if( ( $item = $product->getRefItems( 'media', 'default', 'default' )->first() ) !== null ) {
692
			$this->setMediaUrl( $item->getPreview() );
693
		}
694
695
		return $this->setModified();
696
	}
697
}
698