1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Bukashk0zzzYmlGenerator |
5
|
|
|
* |
6
|
|
|
* (c) Denis Golubovskiy <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Bukashk0zzz\YmlGenerator\Model\Offer; |
13
|
|
|
|
14
|
|
|
use Bukashk0zzz\YmlGenerator\Model\Delivery; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Abstract Class Offer |
18
|
|
|
*/ |
19
|
|
|
abstract class AbstractOffer implements OfferInterface |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var string |
23
|
|
|
*/ |
24
|
|
|
private $id; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var bool |
28
|
|
|
*/ |
29
|
|
|
private $available; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
private $url; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var float |
38
|
|
|
*/ |
39
|
|
|
private $price; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var float |
43
|
|
|
*/ |
44
|
|
|
private $oldPrice; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var float |
48
|
|
|
*/ |
49
|
|
|
private $purchasePrice; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var string |
53
|
|
|
*/ |
54
|
|
|
private $currencyId; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @var int |
58
|
|
|
*/ |
59
|
|
|
private $categoryId; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @var array |
63
|
|
|
*/ |
64
|
|
|
private $categoriesId = []; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @var string |
68
|
|
|
*/ |
69
|
|
|
private $name; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @var string |
73
|
|
|
*/ |
74
|
|
|
private $marketCategory; |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @var bool |
78
|
|
|
*/ |
79
|
|
|
private $adult; |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @var string |
83
|
|
|
*/ |
84
|
|
|
private $salesNotes; |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @var bool |
88
|
|
|
*/ |
89
|
|
|
private $manufacturerWarranty; |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @var bool |
93
|
|
|
*/ |
94
|
|
|
private $pickup; |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @var bool |
98
|
|
|
*/ |
99
|
|
|
private $downloadable; |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @var bool |
103
|
|
|
*/ |
104
|
|
|
private $delivery; |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @var float |
108
|
|
|
*/ |
109
|
|
|
private $localDeliveryCost; |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @var array |
113
|
|
|
*/ |
114
|
|
|
private $deliveryOptions = []; |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @var string |
118
|
|
|
*/ |
119
|
|
|
private $description; |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @var string |
123
|
|
|
*/ |
124
|
|
|
private $countryOfOrigin; |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @var string |
128
|
|
|
*/ |
129
|
|
|
private $weight; |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @var string |
133
|
|
|
*/ |
134
|
|
|
private $dimensions; |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @var int |
138
|
|
|
*/ |
139
|
|
|
private $cpa; |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* @var string[] |
143
|
|
|
*/ |
144
|
|
|
private $barcodes; |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* @var array |
148
|
|
|
*/ |
149
|
|
|
private $pictures = []; |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* @var array |
153
|
|
|
*/ |
154
|
|
|
private $params = []; |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* @var bool |
158
|
|
|
*/ |
159
|
|
|
private $store; |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* @var bool |
163
|
|
|
*/ |
164
|
|
|
private $autoDiscount; |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* Array of custom elements (element types are keys) of arrays of element values |
168
|
|
|
* There may be multiple elements of the same type |
169
|
|
|
* |
170
|
|
|
* @var array[] |
171
|
|
|
*/ |
172
|
|
|
private $customElements; |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* @var OfferCondition |
176
|
|
|
*/ |
177
|
|
|
private $condition; |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* @return array |
181
|
|
|
*/ |
182
|
|
|
public function toArray() |
183
|
|
|
{ |
184
|
|
|
return \array_merge($this->getHeaderOptions(), $this->getOptions(), $this->getFooterOptions()); |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* @return string |
189
|
|
|
*/ |
190
|
|
|
public function getId() |
191
|
|
|
{ |
192
|
|
|
return $this->id; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* @param string $id |
197
|
|
|
* |
198
|
|
|
* @return $this |
199
|
|
|
*/ |
200
|
|
|
public function setId($id) |
201
|
|
|
{ |
202
|
|
|
$this->id = $id; |
203
|
|
|
|
204
|
|
|
return $this; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* @return bool |
209
|
|
|
*/ |
210
|
|
|
public function isAvailable() |
211
|
|
|
{ |
212
|
|
|
return $this->available; |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
/** |
216
|
|
|
* @param bool $available |
217
|
|
|
* |
218
|
|
|
* @return $this |
219
|
|
|
*/ |
220
|
|
|
public function setAvailable($available) |
221
|
|
|
{ |
222
|
|
|
$this->available = $available; |
223
|
|
|
|
224
|
|
|
return $this; |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
/** |
228
|
|
|
* @return string |
229
|
|
|
*/ |
230
|
|
|
public function getUrl() |
231
|
|
|
{ |
232
|
|
|
return $this->url; |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* @param string $url |
237
|
|
|
* |
238
|
|
|
* @return $this |
239
|
|
|
*/ |
240
|
|
|
public function setUrl($url) |
241
|
|
|
{ |
242
|
|
|
$this->url = $url; |
243
|
|
|
|
244
|
|
|
return $this; |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
/** |
248
|
|
|
* @return float |
249
|
|
|
*/ |
250
|
|
|
public function getPrice() |
251
|
|
|
{ |
252
|
|
|
return $this->price; |
253
|
|
|
} |
254
|
|
|
|
255
|
|
|
/** |
256
|
|
|
* @param float $price |
257
|
|
|
* |
258
|
|
|
* @return $this |
259
|
|
|
*/ |
260
|
|
|
public function setPrice($price) |
261
|
|
|
{ |
262
|
|
|
$this->price = $price; |
263
|
|
|
|
264
|
|
|
return $this; |
265
|
|
|
} |
266
|
|
|
|
267
|
|
|
/** |
268
|
|
|
* @return float |
269
|
|
|
*/ |
270
|
|
|
public function getOldPrice() |
271
|
|
|
{ |
272
|
|
|
return $this->oldPrice; |
273
|
|
|
} |
274
|
|
|
|
275
|
|
|
/** |
276
|
|
|
* @param float $oldPrice |
277
|
|
|
* |
278
|
|
|
* @return $this |
279
|
|
|
*/ |
280
|
|
|
public function setOldPrice($oldPrice) |
281
|
|
|
{ |
282
|
|
|
$this->oldPrice = $oldPrice; |
283
|
|
|
|
284
|
|
|
return $this; |
285
|
|
|
} |
286
|
|
|
|
287
|
|
|
/** |
288
|
|
|
* @return float |
289
|
|
|
*/ |
290
|
|
|
public function getPurchasePrice() |
291
|
|
|
{ |
292
|
|
|
return $this->purchasePrice; |
293
|
|
|
} |
294
|
|
|
|
295
|
|
|
/** |
296
|
|
|
* @param float $purchasePrice |
297
|
|
|
* |
298
|
|
|
* @return $this |
299
|
|
|
*/ |
300
|
|
|
public function setPurchasePrice($purchasePrice) |
301
|
|
|
{ |
302
|
|
|
$this->purchasePrice = $purchasePrice; |
303
|
|
|
|
304
|
|
|
return $this; |
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
/** |
308
|
|
|
* @return string |
309
|
|
|
*/ |
310
|
|
|
public function getCurrencyId() |
311
|
|
|
{ |
312
|
|
|
return $this->currencyId; |
313
|
|
|
} |
314
|
|
|
|
315
|
|
|
/** |
316
|
|
|
* @param string $currencyId |
317
|
|
|
* |
318
|
|
|
* @return $this |
319
|
|
|
*/ |
320
|
|
|
public function setCurrencyId($currencyId) |
321
|
|
|
{ |
322
|
|
|
$this->currencyId = $currencyId; |
323
|
|
|
|
324
|
|
|
return $this; |
325
|
|
|
} |
326
|
|
|
|
327
|
|
|
/** |
328
|
|
|
* @return int |
329
|
|
|
*/ |
330
|
|
|
public function getCategoryId() |
331
|
|
|
{ |
332
|
|
|
return $this->categoryId; |
333
|
|
|
} |
334
|
|
|
|
335
|
|
|
/** |
336
|
|
|
* @param int $categoryId |
337
|
|
|
* |
338
|
|
|
* @return $this |
339
|
|
|
*/ |
340
|
|
|
public function setCategoryId($categoryId) |
341
|
|
|
{ |
342
|
|
|
$this->categoryId = $categoryId; |
343
|
|
|
|
344
|
|
|
return $this; |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
/** |
348
|
|
|
* @return array |
349
|
|
|
*/ |
350
|
|
|
public function getCategoriesId() |
351
|
|
|
{ |
352
|
|
|
return $this->categoriesId; |
353
|
|
|
} |
354
|
|
|
|
355
|
|
|
/** |
356
|
|
|
* @param array $categoriesId |
357
|
|
|
* |
358
|
|
|
* @return $this |
359
|
|
|
*/ |
360
|
|
|
public function setCategoriesId(array $categoriesId) |
361
|
|
|
{ |
362
|
|
|
$this->categoriesId = $categoriesId; |
363
|
|
|
|
364
|
|
|
return $this; |
365
|
|
|
} |
366
|
|
|
|
367
|
|
|
/** |
368
|
|
|
* @return string |
369
|
|
|
*/ |
370
|
|
|
public function getName() |
371
|
|
|
{ |
372
|
|
|
return $this->name; |
373
|
|
|
} |
374
|
|
|
|
375
|
|
|
/** |
376
|
|
|
* @param string $name |
377
|
|
|
* |
378
|
|
|
* @return $this |
379
|
|
|
*/ |
380
|
|
|
public function setName($name) |
381
|
|
|
{ |
382
|
|
|
$this->name = $name; |
383
|
|
|
|
384
|
|
|
return $this; |
385
|
|
|
} |
386
|
|
|
|
387
|
|
|
/** |
388
|
|
|
* @return string |
389
|
|
|
*/ |
390
|
|
|
public function getMarketCategory() |
391
|
|
|
{ |
392
|
|
|
return $this->marketCategory; |
393
|
|
|
} |
394
|
|
|
|
395
|
|
|
/** |
396
|
|
|
* @param string $marketCategory |
397
|
|
|
* |
398
|
|
|
* @return $this |
399
|
|
|
*/ |
400
|
|
|
public function setMarketCategory($marketCategory) |
401
|
|
|
{ |
402
|
|
|
$this->marketCategory = $marketCategory; |
403
|
|
|
|
404
|
|
|
return $this; |
405
|
|
|
} |
406
|
|
|
|
407
|
|
|
/** |
408
|
|
|
* @return bool |
409
|
|
|
*/ |
410
|
|
|
public function isAdult() |
411
|
|
|
{ |
412
|
|
|
return $this->adult; |
413
|
|
|
} |
414
|
|
|
|
415
|
|
|
/** |
416
|
|
|
* @param bool $adult |
417
|
|
|
* |
418
|
|
|
* @return $this |
419
|
|
|
*/ |
420
|
|
|
public function setAdult($adult) |
421
|
|
|
{ |
422
|
|
|
$this->adult = $adult; |
423
|
|
|
|
424
|
|
|
return $this; |
425
|
|
|
} |
426
|
|
|
|
427
|
|
|
/** |
428
|
|
|
* @return string |
429
|
|
|
*/ |
430
|
|
|
public function getSalesNotes() |
431
|
|
|
{ |
432
|
|
|
return $this->salesNotes; |
433
|
|
|
} |
434
|
|
|
|
435
|
|
|
/** |
436
|
|
|
* @param string $salesNotes |
437
|
|
|
* |
438
|
|
|
* @return $this |
439
|
|
|
*/ |
440
|
|
|
public function setSalesNotes($salesNotes) |
441
|
|
|
{ |
442
|
|
|
$this->salesNotes = $salesNotes; |
443
|
|
|
|
444
|
|
|
return $this; |
445
|
|
|
} |
446
|
|
|
|
447
|
|
|
/** |
448
|
|
|
* @return bool |
449
|
|
|
*/ |
450
|
|
|
public function isManufacturerWarranty() |
451
|
|
|
{ |
452
|
|
|
return $this->manufacturerWarranty; |
453
|
|
|
} |
454
|
|
|
|
455
|
|
|
/** |
456
|
|
|
* @param bool $manufacturerWarranty |
457
|
|
|
* |
458
|
|
|
* @return $this |
459
|
|
|
*/ |
460
|
|
|
public function setManufacturerWarranty($manufacturerWarranty) |
461
|
|
|
{ |
462
|
|
|
$this->manufacturerWarranty = $manufacturerWarranty; |
463
|
|
|
|
464
|
|
|
return $this; |
465
|
|
|
} |
466
|
|
|
|
467
|
|
|
/** |
468
|
|
|
* @return bool |
469
|
|
|
*/ |
470
|
|
|
public function isPickup() |
471
|
|
|
{ |
472
|
|
|
return $this->pickup; |
473
|
|
|
} |
474
|
|
|
|
475
|
|
|
/** |
476
|
|
|
* @param bool $pickup |
477
|
|
|
* |
478
|
|
|
* @return $this |
479
|
|
|
*/ |
480
|
|
|
public function setPickup($pickup) |
481
|
|
|
{ |
482
|
|
|
$this->pickup = $pickup; |
483
|
|
|
|
484
|
|
|
return $this; |
485
|
|
|
} |
486
|
|
|
|
487
|
|
|
/** |
488
|
|
|
* @return bool |
489
|
|
|
*/ |
490
|
|
|
public function isDownloadable() |
491
|
|
|
{ |
492
|
|
|
return $this->downloadable; |
493
|
|
|
} |
494
|
|
|
|
495
|
|
|
/** |
496
|
|
|
* @param bool $downloadable |
497
|
|
|
* |
498
|
|
|
* @return $this |
499
|
|
|
*/ |
500
|
|
|
public function setDownloadable($downloadable) |
501
|
|
|
{ |
502
|
|
|
$this->downloadable = $downloadable; |
503
|
|
|
|
504
|
|
|
return $this; |
505
|
|
|
} |
506
|
|
|
|
507
|
|
|
/** |
508
|
|
|
* @return bool |
509
|
|
|
*/ |
510
|
|
|
public function isDelivery() |
511
|
|
|
{ |
512
|
|
|
return $this->delivery; |
513
|
|
|
} |
514
|
|
|
|
515
|
|
|
/** |
516
|
|
|
* @param bool $delivery |
517
|
|
|
* |
518
|
|
|
* @return $this |
519
|
|
|
*/ |
520
|
|
|
public function setDelivery($delivery) |
521
|
|
|
{ |
522
|
|
|
$this->delivery = $delivery; |
523
|
|
|
|
524
|
|
|
return $this; |
525
|
|
|
} |
526
|
|
|
|
527
|
|
|
/** |
528
|
|
|
* @return array |
529
|
|
|
*/ |
530
|
|
|
public function getDeliveryOptions() |
531
|
|
|
{ |
532
|
|
|
return $this->deliveryOptions; |
533
|
|
|
} |
534
|
|
|
|
535
|
|
|
/** |
536
|
|
|
* @param Delivery $option |
537
|
|
|
* |
538
|
|
|
* @return $this |
539
|
|
|
*/ |
540
|
|
|
public function addDeliveryOption(Delivery $option) |
541
|
|
|
{ |
542
|
|
|
$this->deliveryOptions[] = $option; |
543
|
|
|
|
544
|
|
|
return $this; |
545
|
|
|
} |
546
|
|
|
|
547
|
|
|
/** |
548
|
|
|
* @param bool $store |
549
|
|
|
* |
550
|
|
|
* @return $this |
551
|
|
|
*/ |
552
|
|
|
public function setStore($store) |
553
|
|
|
{ |
554
|
|
|
$this->store = $store; |
555
|
|
|
|
556
|
|
|
return $this; |
557
|
|
|
} |
558
|
|
|
|
559
|
|
|
/** |
560
|
|
|
* @return bool |
561
|
|
|
*/ |
562
|
|
|
public function isStore() |
563
|
|
|
{ |
564
|
|
|
return $this->store; |
565
|
|
|
} |
566
|
|
|
|
567
|
|
|
/** |
568
|
|
|
* @return float |
569
|
|
|
*/ |
570
|
|
|
public function getLocalDeliveryCost() |
571
|
|
|
{ |
572
|
|
|
return $this->localDeliveryCost; |
573
|
|
|
} |
574
|
|
|
|
575
|
|
|
/** |
576
|
|
|
* @param float $localDeliveryCost |
577
|
|
|
* |
578
|
|
|
* @return $this |
579
|
|
|
*/ |
580
|
|
|
public function setLocalDeliveryCost($localDeliveryCost) |
581
|
|
|
{ |
582
|
|
|
$this->localDeliveryCost = $localDeliveryCost; |
583
|
|
|
|
584
|
|
|
return $this; |
585
|
|
|
} |
586
|
|
|
|
587
|
|
|
/** |
588
|
|
|
* @return string |
589
|
|
|
*/ |
590
|
|
|
public function getDescription() |
591
|
|
|
{ |
592
|
|
|
return $this->description; |
593
|
|
|
} |
594
|
|
|
|
595
|
|
|
/** |
596
|
|
|
* @param string $description |
597
|
|
|
* |
598
|
|
|
* @return $this |
599
|
|
|
*/ |
600
|
|
|
public function setDescription($description) |
601
|
|
|
{ |
602
|
|
|
$this->description = $description; |
603
|
|
|
|
604
|
|
|
return $this; |
605
|
|
|
} |
606
|
|
|
|
607
|
|
|
/** |
608
|
|
|
* @return string |
609
|
|
|
*/ |
610
|
|
|
public function getCountryOfOrigin() |
611
|
|
|
{ |
612
|
|
|
return $this->countryOfOrigin; |
613
|
|
|
} |
614
|
|
|
|
615
|
|
|
/** |
616
|
|
|
* @param string $countryOfOrigin |
617
|
|
|
* |
618
|
|
|
* @return $this |
619
|
|
|
*/ |
620
|
|
|
public function setCountryOfOrigin($countryOfOrigin) |
621
|
|
|
{ |
622
|
|
|
$this->countryOfOrigin = $countryOfOrigin; |
623
|
|
|
|
624
|
|
|
return $this; |
625
|
|
|
} |
626
|
|
|
|
627
|
|
|
/** |
628
|
|
|
* @return string |
629
|
|
|
*/ |
630
|
|
|
public function getWeight() |
631
|
|
|
{ |
632
|
|
|
return $this->weight; |
633
|
|
|
} |
634
|
|
|
|
635
|
|
|
/** |
636
|
|
|
* @param string $weight |
637
|
|
|
* |
638
|
|
|
* @return $this |
639
|
|
|
*/ |
640
|
|
|
public function setWeight($weight) |
641
|
|
|
{ |
642
|
|
|
$this->weight = $weight; |
643
|
|
|
|
644
|
|
|
return $this; |
645
|
|
|
} |
646
|
|
|
|
647
|
|
|
/** |
648
|
|
|
* @return string |
649
|
|
|
*/ |
650
|
|
|
public function getDimensions() |
651
|
|
|
{ |
652
|
|
|
return $this->dimensions; |
653
|
|
|
} |
654
|
|
|
|
655
|
|
|
/** |
656
|
|
|
* @param float $length |
657
|
|
|
* @param float $width |
658
|
|
|
* @param float $height |
659
|
|
|
* |
660
|
|
|
* @return $this |
661
|
|
|
*/ |
662
|
|
|
public function setDimensions($length, $width, $height) |
663
|
|
|
{ |
664
|
|
|
$dimensions = [ |
665
|
|
|
\round((float) $length, 3), |
666
|
|
|
\round((float) $width, 3), |
667
|
|
|
\round((float) $height, 3), |
668
|
|
|
]; |
669
|
|
|
|
670
|
|
|
$this->dimensions = \implode('/', $dimensions); |
671
|
|
|
|
672
|
|
|
return $this; |
673
|
|
|
} |
674
|
|
|
|
675
|
|
|
/** |
676
|
|
|
* @return int |
677
|
|
|
*/ |
678
|
|
|
public function getCpa() |
679
|
|
|
{ |
680
|
|
|
return $this->cpa; |
681
|
|
|
} |
682
|
|
|
|
683
|
|
|
/** |
684
|
|
|
* @param int $cpa |
685
|
|
|
* |
686
|
|
|
* @return $this |
687
|
|
|
*/ |
688
|
|
|
public function setCpa($cpa) |
689
|
|
|
{ |
690
|
|
|
$this->cpa = $cpa; |
691
|
|
|
|
692
|
|
|
return $this; |
693
|
|
|
} |
694
|
|
|
|
695
|
|
|
/** |
696
|
|
|
* @return array |
697
|
|
|
*/ |
698
|
|
|
public function getParams() |
699
|
|
|
{ |
700
|
|
|
return $this->params; |
701
|
|
|
} |
702
|
|
|
|
703
|
|
|
/** |
704
|
|
|
* @param OfferParam $param |
705
|
|
|
* |
706
|
|
|
* @return $this |
707
|
|
|
*/ |
708
|
|
|
public function addParam(OfferParam $param) |
709
|
|
|
{ |
710
|
|
|
$this->params[] = $param; |
711
|
|
|
|
712
|
|
|
return $this; |
713
|
|
|
} |
714
|
|
|
|
715
|
|
|
/** |
716
|
|
|
* Add picture |
717
|
|
|
* |
718
|
|
|
* @param string $url |
719
|
|
|
* |
720
|
|
|
* @return $this |
721
|
|
|
*/ |
722
|
|
|
public function addPicture($url) |
723
|
|
|
{ |
724
|
|
|
if (\count($this->pictures) < 10) { |
725
|
|
|
$this->pictures[] = $url; |
726
|
|
|
} |
727
|
|
|
|
728
|
|
|
return $this; |
729
|
|
|
} |
730
|
|
|
|
731
|
|
|
/** |
732
|
|
|
* Set pictures |
733
|
|
|
* |
734
|
|
|
* @param array $pictures |
735
|
|
|
* |
736
|
|
|
* @return $this |
737
|
|
|
*/ |
738
|
|
|
public function setPictures(array $pictures) |
739
|
|
|
{ |
740
|
|
|
$this->pictures = $pictures; |
741
|
|
|
|
742
|
|
|
return $this; |
743
|
|
|
} |
744
|
|
|
|
745
|
|
|
/** |
746
|
|
|
* Get picture list |
747
|
|
|
* |
748
|
|
|
* @return array |
749
|
|
|
*/ |
750
|
|
|
public function getPictures() |
751
|
|
|
{ |
752
|
|
|
return $this->pictures; |
753
|
|
|
} |
754
|
|
|
|
755
|
|
|
/** |
756
|
|
|
* Get list of barcodes of the offer |
757
|
|
|
* |
758
|
|
|
* @return string[] |
759
|
|
|
*/ |
760
|
|
|
public function getBarcodes() |
761
|
|
|
{ |
762
|
|
|
return $this->barcodes; |
763
|
|
|
} |
764
|
|
|
|
765
|
|
|
/** |
766
|
|
|
* Set list of barcodes for that offer |
767
|
|
|
* |
768
|
|
|
* @param string[] $barcodes |
769
|
|
|
* |
770
|
|
|
* @return $this |
771
|
|
|
*/ |
772
|
|
|
public function setBarcodes(array $barcodes = []) |
773
|
|
|
{ |
774
|
|
|
$this->barcodes = $barcodes; |
775
|
|
|
|
776
|
|
|
return $this; |
777
|
|
|
} |
778
|
|
|
|
779
|
|
|
/** |
780
|
|
|
* Add one barcode to the collection of barcodes of this offer |
781
|
|
|
* |
782
|
|
|
* @param string $barcode |
783
|
|
|
* |
784
|
|
|
* @return $this |
785
|
|
|
*/ |
786
|
|
|
public function addBarcode($barcode) |
787
|
|
|
{ |
788
|
|
|
$this->barcodes[] = $barcode; |
789
|
|
|
|
790
|
|
|
return $this; |
791
|
|
|
} |
792
|
|
|
|
793
|
|
|
/** |
794
|
|
|
* Sets list of custom elements |
795
|
|
|
* |
796
|
|
|
* @param array $customElements Array (keys are element types) of arrays (element values) |
797
|
|
|
* |
798
|
|
|
* @return $this |
799
|
|
|
*/ |
800
|
|
|
public function setCustomElements(array $customElements = []) |
801
|
|
|
{ |
802
|
|
|
$this->customElements = $customElements; |
803
|
|
|
|
804
|
|
|
return $this; |
805
|
|
|
} |
806
|
|
|
|
807
|
|
|
/** |
808
|
|
|
* Add a custom element with given type and value |
809
|
|
|
* Multiple elements of the same type are supported |
810
|
|
|
* |
811
|
|
|
* @param string $elementType |
812
|
|
|
* @param mixed $value |
813
|
|
|
* |
814
|
|
|
* @return $this |
815
|
|
|
*/ |
816
|
|
|
public function addCustomElement($elementType, $value) |
817
|
|
|
{ |
818
|
|
|
if ($value !== null) { |
819
|
|
|
// Add value to the list of values of the given element type creating array when needed |
820
|
|
|
$this->customElements[$elementType][] = $value; |
821
|
|
|
} |
822
|
|
|
|
823
|
|
|
return $this; |
824
|
|
|
} |
825
|
|
|
|
826
|
|
|
/** |
827
|
|
|
* Returns a list of custom elements |
828
|
|
|
* Always returns an array even if no custom elements were added |
829
|
|
|
* |
830
|
|
|
* @return array |
831
|
|
|
*/ |
832
|
|
|
public function getCustomElements() |
833
|
|
|
{ |
834
|
|
|
return $this->customElements ?: []; |
835
|
|
|
} |
836
|
|
|
|
837
|
|
|
/** |
838
|
|
|
* Returns a list of values for the specified custom element type |
839
|
|
|
* Always returns an array |
840
|
|
|
* |
841
|
|
|
* @param string $elementType |
842
|
|
|
* |
843
|
|
|
* @return array |
844
|
|
|
*/ |
845
|
|
|
public function getCustomElementByType($elementType) |
846
|
|
|
{ |
847
|
|
|
// TODO: Use ?? operator when support for PHP 5.6 is no longer needed |
848
|
|
|
if (isset($this->customElements[$elementType])) { |
849
|
|
|
return $this->customElements[$elementType]; |
850
|
|
|
} |
851
|
|
|
|
852
|
|
|
return []; |
853
|
|
|
} |
854
|
|
|
|
855
|
|
|
/** |
856
|
|
|
* @return OfferCondition |
857
|
|
|
*/ |
858
|
|
|
public function getCondition() |
859
|
|
|
{ |
860
|
|
|
return $this->condition; |
861
|
|
|
} |
862
|
|
|
|
863
|
|
|
/** |
864
|
|
|
* @param OfferCondition $condition |
865
|
|
|
* |
866
|
|
|
* @return $this |
867
|
|
|
*/ |
868
|
|
|
public function addCondition(OfferCondition $condition) |
869
|
|
|
{ |
870
|
|
|
$this->condition = $condition; |
871
|
|
|
|
872
|
|
|
return $this; |
873
|
|
|
} |
874
|
|
|
|
875
|
|
|
/** |
876
|
|
|
* @return bool |
877
|
|
|
*/ |
878
|
|
|
public function getAutoDiscount() |
879
|
|
|
{ |
880
|
|
|
return $this->autoDiscount; |
881
|
|
|
} |
882
|
|
|
|
883
|
|
|
/** |
884
|
|
|
* @param bool $autoDiscount |
885
|
|
|
* |
886
|
|
|
* @return $this |
887
|
|
|
*/ |
888
|
|
|
public function setAutoDiscount($autoDiscount) |
889
|
|
|
{ |
890
|
|
|
$this->autoDiscount = $autoDiscount; |
891
|
|
|
|
892
|
|
|
return $this; |
893
|
|
|
} |
894
|
|
|
|
895
|
|
|
/** |
896
|
|
|
* @return array |
897
|
|
|
*/ |
898
|
|
|
abstract protected function getOptions(); |
899
|
|
|
|
900
|
|
|
/** |
901
|
|
|
* @return array |
902
|
|
|
*/ |
903
|
|
|
private function getHeaderOptions() |
904
|
|
|
{ |
905
|
|
|
return [ |
906
|
|
|
'url' => $this->getUrl(), |
907
|
|
|
'price' => $this->getPrice(), |
908
|
|
|
'oldprice' => $this->getOldPrice(), |
909
|
|
|
'purchase_price' => $this->getPurchasePrice(), |
910
|
|
|
'currencyId' => $this->getCurrencyId(), |
911
|
|
|
'categoryId' => \array_merge( |
912
|
|
|
[$this->getCategoryId()], |
913
|
|
|
$this->getCategoriesId() |
914
|
|
|
), |
915
|
|
|
'market_category' => $this->getMarketCategory(), |
916
|
|
|
'picture' => $this->getPictures(), |
917
|
|
|
'pickup' => $this->isPickup(), |
918
|
|
|
'store' => $this->isStore(), |
919
|
|
|
'delivery' => $this->isDelivery(), |
920
|
|
|
'local_delivery_cost' => $this->getLocalDeliveryCost(), |
921
|
|
|
'weight' => $this->getWeight(), |
922
|
|
|
'dimensions' => $this->getDimensions(), |
923
|
|
|
'name' => $this->getName(), |
924
|
|
|
'enable_auto_discounts' => $this->getAutoDiscount(), |
925
|
|
|
] + $this->getCustomElements(); |
926
|
|
|
} |
927
|
|
|
|
928
|
|
|
/** |
929
|
|
|
* @return array |
930
|
|
|
*/ |
931
|
|
|
private function getFooterOptions() |
932
|
|
|
{ |
933
|
|
|
return [ |
934
|
|
|
'description' => $this->getDescription(), |
935
|
|
|
'sales_notes' => $this->getSalesNotes(), |
936
|
|
|
'manufacturer_warranty' => $this->isManufacturerWarranty(), |
937
|
|
|
'country_of_origin' => $this->getCountryOfOrigin(), |
938
|
|
|
'downloadable' => $this->isDownloadable(), |
939
|
|
|
'adult' => $this->isAdult(), |
940
|
|
|
'cpa' => $this->getCpa(), |
941
|
|
|
'barcode' => $this->getBarcodes(), |
942
|
|
|
]; |
943
|
|
|
} |
944
|
|
|
} |
945
|
|
|
|