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