Passed
Push — master ( 98ef81...be5b4c )
by Aimeos
04:25
created

Standard::getScale()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 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-2022
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 vendor.
177
	 *
178
	 * @return string Vendor name
179
	 */
180
	public function getVendor() : string
181
	{
182
		return $this->get( 'order.base.product.vendor', '' );
183
	}
184
185
186
	/**
187
	 * Sets the vendor.
188
	 *
189
	 * @param string|null $value Vendor name
190
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order base product item for chaining method calls
191
	 */
192
	public function setVendor( ?string $value ) : \Aimeos\MShop\Order\Item\Base\Product\Iface
193
	{
194
		return $this->set( 'order.base.product.vendor', (string) $value );
195
	}
196
197
198
	/**
199
	 * Returns the product ID the customer has selected.
200
	 *
201
	 * @return string Original product ID
202
	 */
203
	public function getProductId() : string
204
	{
205
		return $this->get( 'order.base.product.productid', '' );
206
	}
207
208
209
	/**
210
	 * Sets the ID of a product the customer has selected.
211
	 *
212
	 * @param string|null $id Product Code ID
213
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order base product item for chaining method calls
214
	 */
215
	public function setProductId( ?string $id ) : \Aimeos\MShop\Order\Item\Base\Product\Iface
216
	{
217
		return $this->set( 'order.base.product.productid', (string) $id );
218
	}
219
220
221
	/**
222
	 * Returns the product ID of the parent product.
223
	 *
224
	 * @return string Product ID of the parent product
225
	 */
226
	public function getParentProductId() : string
227
	{
228
		return $this->get( 'order.base.product.parentproductid', '' );
229
	}
230
231
232
	/**
233
	 * Sets the ID of the parent product the customer has selected.
234
	 *
235
	 * @param string|null $id Product ID of the parent product
236
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order base product item for chaining method calls
237
	 */
238
	public function setParentProductId( ?string $id ) : \Aimeos\MShop\Order\Item\Base\Product\Iface
239
	{
240
		return $this->set( 'order.base.product.parentproductid', (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|null $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( (string) $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|null $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', (string) $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|null $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', (string) $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|null $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', (string) $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|null $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', (string) $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|null $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', (string) $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 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', $this->getQuantity() );
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 ordered quantity' ) );
453
		}
454
455
		return $this->set( 'order.base.product.qtyopen', $quantity );
456
	}
457
458
459
	/**
460
	 * Returns the quantity scale of the product.
461
	 *
462
	 * @return float Minimum quantity value
463
	 */
464
	public function getScale() : float
465
	{
466
		return (float) $this->get( 'order.base.product.scale', 1 );
467
	}
468
469
470
	/**
471
	 * Sets the quantity scale of the product.
472
	 *
473
	 * @param float $quantity Minimum quantity value
474
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order base product item for chaining method calls
475
	 */
476
	public function setScale( float $quantity ) : \Aimeos\MShop\Order\Item\Base\Product\Iface
477
	{
478
		if( $quantity <= 0 ) {
479
			throw new \Aimeos\MShop\Order\Exception( sprintf( 'Quantity scale must be greater than 0' ) );
480
		}
481
482
		return $this->set( 'order.base.product.scale', $quantity );
483
	}
484
485
486
	/**
487
	 * 	Returns the flags for the product item.
488
	 *
489
	 * @return int Flags, e.g. for immutable products
490
	 */
491
	public function getFlags() : int
492
	{
493
		return $this->get( 'order.base.product.flags', \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_NONE );
494
	}
495
496
497
	/**
498
	 * Sets the new value for the product item flags.
499
	 *
500
	 * @param int $value Flags, e.g. for immutable products
501
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order base product item for chaining method calls
502
	 */
503
	public function setFlags( int $value ) : \Aimeos\MShop\Order\Item\Base\Product\Iface
504
	{
505
		return $this->set( 'order.base.product.flags', $this->checkFlags( $value ) );
506
	}
507
508
509
	/**
510
	 * Returns the position of the product in the order.
511
	 *
512
	 * @return int|null Product position in the order from 0-n
513
	 */
514
	public function getPosition() : ?int
515
	{
516
		return $this->get( 'order.base.product.position' );
517
	}
518
519
520
	/**
521
	 * Sets the position of the product within the list of ordered products.
522
	 *
523
	 * @param int|null $value Product position in the order from 0-n or null for resetting the position
524
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order base product item for chaining method calls
525
	 * @throws \Aimeos\MShop\Order\Exception If the position is invalid
526
	 */
527
	public function setPosition( ?int $value ) : \Aimeos\MShop\Order\Item\Base\Product\Iface
528
	{
529
		if( $value < 0 ) {
530
			throw new \Aimeos\MShop\Order\Exception( sprintf( 'Order product position "%1$s" must be greater than 0', $value ) );
531
		}
532
533
		return $this->set( 'order.base.product.position', ( $value !== null ? $value : null ) );
534
	}
535
536
537
	/**
538
	 * Returns the current delivery status of the order product item.
539
	 *
540
	 * The returned status values are the STAT_* constants from the \Aimeos\MShop\Order\Item\Base class
541
	 *
542
	 * @return int Delivery status of the product
543
	 */
544
	public function getStatusDelivery() : int
545
	{
546
		return $this->get( 'order.base.product.statusdelivery', -1 );
547
	}
548
549
550
	/**
551
	 * Sets the new delivery status of the order product item.
552
	 *
553
	 * Possible status values are the STAT_* constants from the \Aimeos\MShop\Order\Item\Base class
554
	 *
555
	 * @param int $value New delivery status of the product
556
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order base product item for chaining method calls
557
	 */
558
	public function setStatusDelivery( int $value ) : \Aimeos\MShop\Order\Item\Base\Product\Iface
559
	{
560
		return $this->set( 'order.base.product.statusdelivery', $value );
561
	}
562
563
564
	/**
565
	 * Returns the current payment status of the order product item.
566
	 *
567
	 * The returned status values are the PAY_* constants from the \Aimeos\MShop\Order\Item\Base class
568
	 *
569
	 * @return int Payment status of the product
570
	 */
571
	public function getStatusPayment() : int
572
	{
573
		return $this->get( 'order.base.product.statuspayment', -1 );
574
	}
575
576
577
	/**
578
	 * Sets the new payment status of the order product item.
579
	 *
580
	 * Possible status values are the PAY_* constants from the \Aimeos\MShop\Order\Item\Base class
581
	 *
582
	 * @param int $value New payment status of the product
583
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order base product item for chaining method calls
584
	 */
585
	public function setStatusPayment( int $value ) : \Aimeos\MShop\Order\Item\Base\Product\Iface
586
	{
587
		return $this->set( 'order.base.product.statuspayment', $value );
588
	}
589
590
591
	/**
592
	 * Returns the notes for the ordered product.
593
	 *
594
	 * @return string Notes for the ordered product
595
	 */
596
	public function getNotes() : string
597
	{
598
		return $this->get( 'order.base.product.notes', '' );
599
	}
600
601
602
	/**
603
	 * Sets the notes for the ordered product.
604
	 *
605
	 * @param string|null $value Notes for the ordered product
606
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order base product item for chaining method calls
607
	 */
608
	public function setNotes( ?string $value ) : \Aimeos\MShop\Order\Item\Base\Product\Iface
609
	{
610
		return $this->set( 'order.base.product.notes', (string) $value );
611
	}
612
613
614
	/*
615
	 * Sets the item values from the given array and removes that entries from the list
616
	 *
617
	 * @param array &$list Associative list of item keys and their values
618
	 * @param bool True to set private properties too, false for public only
619
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order product item for chaining method calls
620
	 */
621
	public function fromArray( array &$list, bool $private = false ) : \Aimeos\MShop\Common\Item\Iface
622
	{
623
		$price = $this->getPrice();
624
		$item = parent::fromArray( $list, $private );
625
626
		foreach( $list as $key => $value )
627
		{
628
			switch( $key )
629
			{
630
				case 'order.base.product.siteid': !$private ?: $item = $item->setSiteId( $value ); break;
631
				case 'order.base.product.baseid': !$private ?: $item = $item->setBaseId( $value ); break;
632
				case 'order.base.product.orderproductid': !$private ?: $item = $item->setOrderProductId( $value ); break;
633
				case 'order.base.product.orderaddressid': !$private ?: $item = $item->setOrderAddressId( $value ); break;
634
				case 'order.base.product.position': !$private ?: $item = $item->setPosition( (int) $value ); break;
635
				case 'order.base.product.flags': !$private ?: $item = $item->setFlags( (int) $value ); break;
636
				case 'order.base.product.target': !$private ?: $item = $item->setTarget( $value ); break;
637
				case 'order.base.product.parentproductid': $item = $item->setParentProductId( $value ); break;
638
				case 'order.base.product.productid': $item = $item->setProductId( $value ); break;
639
				case 'order.base.product.prodcode': $item = $item->setProductCode( $value ); break;
640
				case 'order.base.product.vendor': $item = $item->setVendor( $value ); break;
641
				case 'order.base.product.stocktype': $item = $item->setStockType( $value ); break;
642
				case 'order.base.product.type': $item = $item->setType( $value ); break;
643
				case 'order.base.product.currencyid': $price = $price->setCurrencyId( $value ); break;
644
				case 'order.base.product.price': $price = $price->setValue( $value ); break;
645
				case 'order.base.product.costs': $price = $price->setCosts( $value ); break;
646
				case 'order.base.product.rebate': $price = $price->setRebate( $value ); break;
647
				case 'order.base.product.taxrates': $price = $price->setTaxRates( $value ); break;
648
				case 'order.base.product.taxvalue': $price = $price->setTaxValue( $value ); break;
649
				case 'order.base.product.taxflag': $price = $price->setTaxFlag( $value ); break;
650
				case 'order.base.product.name': $item = $item->setName( $value ); break;
651
				case 'order.base.product.description': $item = $item->setDescription( $value ); break;
652
				case 'order.base.product.mediaurl': $item = $item->setMediaUrl( $value ); break;
653
				case 'order.base.product.timeframe': $item = $item->setTimeFrame( $value ); break;
654
				case 'order.base.product.scale': $item = $item->setScale( (float) $value ); break;
655
				case 'order.base.product.quantity': $item = $item->setQuantity( (float) $value ); break;
656
				case 'order.base.product.qtyopen': $item = $item->setQuantityOpen( (float) $value ); break;
657
				case 'order.base.product.notes': $item = $item->setNotes( (string) $value ); break;
658
				case 'order.base.product.statusdelivery': $item = $item->setStatusDelivery( (int) $value ); break;
659
				case 'order.base.product.statuspayment': $item = $item->setStatusPayment( (int) $value ); break;
660
				default: continue 2;
661
			}
662
663
			unset( $list[$key] );
664
		}
665
666
		return $item;
667
	}
668
669
670
	/**
671
	 * Returns the item values as associative list.
672
	 *
673
	 * @param bool True to return private properties, false for public only
674
	 * @return array Associative list of item properties and their values
675
	 */
676
	public function toArray( bool $private = false ) : array
677
	{
678
		$price = $this->getPrice();
679
		$list = parent::toArray( $private );
680
681
		$list['order.base.product.type'] = $this->getType();
682
		$list['order.base.product.stocktype'] = $this->getStockType();
683
		$list['order.base.product.prodcode'] = $this->getProductCode();
684
		$list['order.base.product.productid'] = $this->getProductId();
685
		$list['order.base.product.parentproductid'] = $this->getParentProductId();
686
		$list['order.base.product.vendor'] = $this->getVendor();
687
		$list['order.base.product.scale'] = $this->getScale();
688
		$list['order.base.product.quantity'] = $this->getQuantity();
689
		$list['order.base.product.qtyopen'] = $this->getQuantityOpen();
690
		$list['order.base.product.currencyid'] = $price->getCurrencyId();
691
		$list['order.base.product.price'] = $price->getValue();
692
		$list['order.base.product.costs'] = $price->getCosts();
693
		$list['order.base.product.rebate'] = $price->getRebate();
694
		$list['order.base.product.taxrates'] = $price->getTaxRates();
695
		$list['order.base.product.taxvalue'] = $price->getTaxValue();
696
		$list['order.base.product.taxflag'] = $price->getTaxFlag();
697
		$list['order.base.product.name'] = $this->getName();
698
		$list['order.base.product.description'] = $this->getDescription();
699
		$list['order.base.product.mediaurl'] = $this->getMediaUrl();
700
		$list['order.base.product.timeframe'] = $this->getTimeFrame();
701
		$list['order.base.product.position'] = $this->getPosition();
702
		$list['order.base.product.notes'] = $this->getNotes();
703
		$list['order.base.product.statuspayment'] = $this->getStatusPayment();
704
		$list['order.base.product.statusdelivery'] = $this->getStatusDelivery();
705
706
		if( $private === true )
707
		{
708
			$list['order.base.product.baseid'] = $this->getBaseId();
709
			$list['order.base.product.orderproductid'] = $this->getOrderProductId();
710
			$list['order.base.product.orderaddressid'] = $this->getOrderAddressId();
711
			$list['order.base.product.target'] = $this->getTarget();
712
			$list['order.base.product.flags'] = $this->getFlags();
713
		}
714
715
		return $list;
716
	}
717
718
	/**
719
	 * Compares the properties of the given order product item with its own ones.
720
	 *
721
	 * @param \Aimeos\MShop\Order\Item\Base\Product\Iface $item Order product item
722
	 * @return bool True if the item properties are equal, false if not
723
	 * @since 2014.09
724
	 */
725
	public function compare( \Aimeos\MShop\Order\Item\Base\Product\Iface $item ) : bool
726
	{
727
		if( $this->getFlags() === $item->getFlags()
728
			&& $this->getName() === $item->getName()
729
			&& $this->getSiteId() === $item->getSiteId()
730
			&& $this->getStockType() === $item->getStockType()
731
			&& $this->getProductCode() === $item->getProductCode()
732
			&& $this->getOrderAddressId() === $item->getOrderAddressId()
733
		) {
734
			return true;
735
		}
736
737
		return false;
738
	}
739
740
741
	/**
742
	 * Copys all data from a given product item.
743
	 *
744
	 * @param \Aimeos\MShop\Product\Item\Iface $product Product item to copy from
745
	 * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order product item for chaining method calls
746
	 */
747
	public function copyFrom( \Aimeos\MShop\Product\Item\Iface $product ) : \Aimeos\MShop\Order\Item\Base\Product\Iface
748
	{
749
		$values = $product->toArray();
750
		$this->fromArray( $values );
751
752
		$this->setSiteId( $product->getSiteId() );
753
		$this->setProductCode( $product->getCode() );
754
		$this->setProductId( $product->getId() );
755
		$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

755
		$this->setType( /** @scrutinizer ignore-type */ $product->getType() );
Loading history...
756
		$this->setScale( $product->getScale() );
757
		$this->setTarget( $product->getTarget() );
758
		$this->setName( $product->getName() );
759
760
		if( $item = $product->getRefItems( 'text', 'basket', 'default' )->first() ) {
761
			$this->setDescription( $item->getContent() );
762
		}
763
764
		if( $item = $product->getRefItems( 'media', 'default', 'default' )->first() ) {
765
			$this->setMediaUrl( $item->getPreview() );
766
		}
767
768
		if( $item = $product->getSiteItem() ) {
769
			$this->setVendor( $item->getLabel() );
770
		}
771
772
		return $this->setModified();
773
	}
774
}
775