1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* TechDivision\Import\Product\Subjects\BunchSubject |
5
|
|
|
* |
6
|
|
|
* NOTICE OF LICENSE |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
9
|
|
|
* that is available through the world-wide-web at this URL: |
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
11
|
|
|
* |
12
|
|
|
* PHP version 5 |
13
|
|
|
* |
14
|
|
|
* @author Tim Wagner <[email protected]> |
15
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
16
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
17
|
|
|
* @link https://github.com/techdivision/import-product |
18
|
|
|
* @link http://www.techdivision.com |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace TechDivision\Import\Product\Subjects; |
22
|
|
|
|
23
|
|
|
use Goodby\CSV\Export\Standard\Exporter; |
24
|
|
|
use Goodby\CSV\Export\Standard\ExporterConfig; |
25
|
|
|
use TechDivision\Import\Utils\RegistryKeys; |
26
|
|
|
use TechDivision\Import\Services\RegistryProcessor; |
27
|
|
|
use TechDivision\Import\Product\Utils\VisibilityKeys; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* The subject implementation that handles the business logic to persist products. |
31
|
|
|
* |
32
|
|
|
* @author Tim Wagner <[email protected]> |
33
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
34
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
35
|
|
|
* @link https://github.com/techdivision/import-product |
36
|
|
|
* @link http://www.techdivision.com |
37
|
|
|
*/ |
38
|
|
|
class BunchSubject extends AbstractProductSubject |
39
|
|
|
{ |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* The mapping for the supported backend types (for the product entity) => persist methods. |
43
|
|
|
* |
44
|
|
|
* @var array |
45
|
|
|
*/ |
46
|
|
|
protected $backendTypes = array( |
47
|
|
|
'datetime' => array('persistProductDatetimeAttribute', 'loadProductDatetimeAttribute'), |
48
|
|
|
'decimal' => array('persistProductDecimalAttribute', 'loadProductDecimalAttribute'), |
49
|
|
|
'int' => array('persistProductIntAttribute', 'loadProductIntAttribute'), |
50
|
|
|
'text' => array('persistProductTextAttribute', 'loadProductTextAttribute'), |
51
|
|
|
'varchar' => array('persistProductVarcharAttribute', 'loadProductVarcharAttribute') |
52
|
|
|
); |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Mappings for attribute code => CSV column header. |
56
|
|
|
* |
57
|
|
|
* @var array |
58
|
|
|
*/ |
59
|
|
|
protected $headerMappings = array( |
60
|
|
|
'status' => 'product_online', |
61
|
|
|
'tax_class_id' => 'tax_class_name', |
62
|
|
|
'price_type' => 'bundle_price_type', |
63
|
|
|
'sku_type' => 'bundle_sku_type', |
64
|
|
|
'price_view' => 'bundle_price_view', |
65
|
|
|
'weight_type' => 'bundle_weight_type', |
66
|
|
|
'image' => 'base_image', |
67
|
|
|
'image_label' => 'base_image_label', |
68
|
|
|
'thumbnail' => 'thumbnail_image', |
69
|
|
|
'thumbnail_label' => 'thumbnail_image_label' |
70
|
|
|
); |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Mappings for the table column => CSV column header. |
74
|
|
|
* |
75
|
|
|
* @var array |
76
|
|
|
*/ |
77
|
|
|
protected $headerStockMappings = array( |
78
|
|
|
'qty' => array('qty', 'float'), |
79
|
|
|
'min_qty' => array('out_of_stock_qty', 'float'), |
80
|
|
|
'use_config_min_qty' => array('use_config_min_qty', 'int'), |
81
|
|
|
'is_qty_decimal' => array('is_qty_decimal', 'int'), |
82
|
|
|
'backorders' => array('allow_backorders', 'int'), |
83
|
|
|
'use_config_backorders' => array('use_config_backorders', 'int'), |
84
|
|
|
'min_sale_qty' => array('min_cart_qty', 'float'), |
85
|
|
|
'use_config_min_sale_qty' => array('use_config_min_sale_qty', 'int'), |
86
|
|
|
'max_sale_qty' => array('max_cart_qty', 'float'), |
87
|
|
|
'use_config_max_sale_qty' => array('use_config_max_sale_qty', 'int'), |
88
|
|
|
'is_in_stock' => array('is_in_stock', 'int'), |
89
|
|
|
'notify_stock_qty' => array('notify_on_stock_below', 'float'), |
90
|
|
|
'use_config_notify_stock_qty' => array('use_config_notify_stock_qty', 'int'), |
91
|
|
|
'manage_stock' => array('manage_stock', 'int'), |
92
|
|
|
'use_config_manage_stock' => array('use_config_manage_stock', 'int'), |
93
|
|
|
'use_config_qty_increments' => array('use_config_qty_increments', 'int'), |
94
|
|
|
'qty_increments' => array('qty_increments', 'float'), |
95
|
|
|
'use_config_enable_qty_inc' => array('use_config_enable_qty_inc', 'int'), |
96
|
|
|
'enable_qty_increments' => array('enable_qty_increments', 'int'), |
97
|
|
|
'is_decimal_divided' => array('is_decimal_divided', 'int'), |
98
|
|
|
); |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* The array with the available visibility keys. |
102
|
|
|
* |
103
|
|
|
* @var array |
104
|
|
|
*/ |
105
|
|
|
protected $availableVisibilities = array( |
106
|
|
|
'Not Visible Individually' => VisibilityKeys::VISIBILITY_NOT_VISIBLE, |
107
|
|
|
'Catalog' => VisibilityKeys::VISIBILITY_IN_CATALOG, |
108
|
|
|
'Search' => VisibilityKeys::VISIBILITY_IN_SEARCH, |
109
|
|
|
'Catalog, Search' => VisibilityKeys::VISIBILITY_BOTH |
110
|
|
|
); |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* The attribute set of the product that has to be created. |
114
|
|
|
* |
115
|
|
|
* @var array |
116
|
|
|
*/ |
117
|
|
|
protected $attributeSet = array(); |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* The array containing the data for product type configuration (configurables, bundles, etc). |
121
|
|
|
* |
122
|
|
|
* @var array |
123
|
|
|
*/ |
124
|
|
|
protected $artefacs = array(); |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* The mapping for the SKUs to the created entity IDs. |
128
|
|
|
* |
129
|
|
|
* @var array |
130
|
|
|
*/ |
131
|
|
|
protected $skuEntityIdMapping = array(); |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* The category IDs the product is related with. |
135
|
|
|
* |
136
|
|
|
* @var array |
137
|
|
|
*/ |
138
|
|
|
protected $productCategoryIds = array(); |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Set's the attribute set of the product that has to be created. |
142
|
|
|
* |
143
|
|
|
* @param array $attributeSet The attribute set |
144
|
|
|
* |
145
|
|
|
* @return void |
146
|
|
|
*/ |
147
|
1 |
|
public function setAttributeSet(array $attributeSet) |
148
|
|
|
{ |
149
|
1 |
|
$this->attributeSet = $attributeSet; |
150
|
1 |
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* Return's the attribute set of the product that has to be created. |
154
|
|
|
* |
155
|
|
|
* @return array The attribute set |
156
|
|
|
*/ |
157
|
|
|
public function getAttributeSet() |
158
|
|
|
{ |
159
|
|
|
return $this->attributeSet; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* Clean up the global data after importing the bunch. |
164
|
|
|
* |
165
|
|
|
* @return void |
166
|
|
|
*/ |
167
|
|
|
public function tearDown() |
168
|
|
|
{ |
169
|
|
|
|
170
|
|
|
// invoke parent method |
171
|
|
|
parent::tearDown(); |
172
|
|
|
|
173
|
|
|
// export the artefacts |
174
|
|
|
$this->exportArtefacts(); |
175
|
|
|
|
176
|
|
|
// load the registry processor |
177
|
|
|
$registryProcessor = $this->getRegistryProcessor(); |
178
|
|
|
|
179
|
|
|
// update the status with the SKU => entity ID mapping |
180
|
|
|
$registryProcessor->mergeAttributesRecursive( |
181
|
|
|
$this->getSerial(), |
182
|
|
|
array(RegistryKeys::SKU_ENTITY_ID_MAPPING => $this->skuEntityIdMapping) |
183
|
|
|
); |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* Export's the artefacts to CSV files. |
188
|
|
|
* |
189
|
|
|
* @return void |
190
|
|
|
*/ |
191
|
|
|
public function exportArtefacts() |
192
|
|
|
{ |
193
|
|
|
|
194
|
|
|
// load the target directory and the actual timestamp |
195
|
|
|
$targetDir = $this->getConfiguration()->getTargetDir(); |
196
|
|
|
$timestamp = date('Ymd-His'); |
197
|
|
|
|
198
|
|
|
// initialize the counter |
199
|
|
|
$counter = 0; |
200
|
|
|
|
201
|
|
|
// iterate over the artefacts and export them |
202
|
|
|
foreach ($this->getArtefacts() as $artefactType => $artefacts) { |
203
|
|
|
foreach ($artefacts as $entityArtefacts) { |
204
|
|
|
// initialize the the exporter |
205
|
|
|
$exporter = new Exporter($this->getExportConfig()); |
206
|
|
|
|
207
|
|
|
// initialize the bunch |
208
|
|
|
$bunch = array(); |
209
|
|
|
|
210
|
|
|
// set the bunch header and append the artefact data |
211
|
|
|
$first = reset($entityArtefacts); |
212
|
|
|
$second = reset($first); |
213
|
|
|
$bunch[] = array_keys($second); |
214
|
|
|
|
215
|
|
|
// export the artefacts |
216
|
|
|
foreach ($entityArtefacts as $entityArtefact) { |
217
|
|
|
$bunch = array_merge($bunch, $entityArtefact); |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
// export the artefact (bunch) |
221
|
|
|
$exporter->export(sprintf('%s/%s-%s_%d.csv', $targetDir, $artefactType, $timestamp, $counter++), $bunch); |
222
|
|
|
} |
223
|
|
|
} |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
/** |
227
|
|
|
* Initialize and return the exporter configuration. |
228
|
|
|
* |
229
|
|
|
* @return \Goodby\CSV\Export\Standard\ExporterConfig The exporter configuration |
230
|
|
|
*/ |
231
|
|
|
protected function getExportConfig() |
232
|
|
|
{ |
233
|
|
|
|
234
|
|
|
// initialize the lexer configuration |
235
|
|
|
$config = new ExporterConfig(); |
236
|
|
|
|
237
|
|
|
// query whether or not a delimiter character has been configured |
238
|
|
|
if ($delimiter = $this->getConfiguration()->getDelimiter()) { |
239
|
|
|
$config->setDelimiter($delimiter); |
240
|
|
|
} |
241
|
|
|
|
242
|
|
|
// query whether or not a custom escape character has been configured |
243
|
|
|
if ($escape = $this->getConfiguration()->getEscape()) { |
244
|
|
|
$config->setEscape($escape); |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
// query whether or not a custom enclosure character has been configured |
248
|
|
|
if ($enclosure = $this->getConfiguration()->getEnclosure()) { |
249
|
|
|
$config->setEnclosure($enclosure); |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
// query whether or not a custom source charset has been configured |
253
|
|
|
if ($fromCharset = $this->getConfiguration()->getFromCharset()) { |
254
|
|
|
$config->setFromCharset($fromCharset); |
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
// query whether or not a custom target charset has been configured |
258
|
|
|
if ($toCharset = $this->getConfiguration()->getToCharset()) { |
259
|
|
|
$config->setToCharset($toCharset); |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
// query whether or not a custom file mode has been configured |
263
|
|
|
if ($fileMode = $this->getConfiguration()->getFileMode()) { |
264
|
|
|
$config->setFileMode($fileMode); |
265
|
|
|
} |
266
|
|
|
|
267
|
|
|
// return the lexer configuratio |
268
|
|
|
return $config; |
269
|
|
|
} |
270
|
|
|
|
271
|
|
|
/** |
272
|
|
|
* Cast's the passed value based on the backend type information. |
273
|
|
|
* |
274
|
|
|
* @param string $backendType The backend type to cast to |
275
|
|
|
* @param mixed $value The value to be casted |
276
|
|
|
* |
277
|
|
|
* @return mixed The casted value |
278
|
|
|
*/ |
279
|
|
|
public function castValueByBackendType($backendType, $value) |
280
|
|
|
{ |
281
|
|
|
|
282
|
|
|
// cast the value to a valid timestamp |
283
|
|
|
if ($backendType === 'datetime') { |
284
|
|
|
return \DateTime::createFromFormat($this->getSourceDateFormat(), $value)->format('Y-m-d H:i:s'); |
285
|
|
|
} |
286
|
|
|
|
287
|
|
|
// cast the value to a float value |
288
|
|
|
if ($backendType === 'float') { |
289
|
|
|
return (float) $value; |
290
|
|
|
} |
291
|
|
|
|
292
|
|
|
// cast the value to an integer |
293
|
|
|
if ($backendType === 'int') { |
294
|
|
|
return (int) $value; |
295
|
|
|
} |
296
|
|
|
|
297
|
|
|
// we don't need to cast strings |
298
|
|
|
return $value; |
299
|
|
|
} |
300
|
|
|
|
301
|
|
|
/** |
302
|
|
|
* Return's the mappings for the table column => CSV column header. |
303
|
|
|
* |
304
|
|
|
* @return array The header stock mappings |
305
|
|
|
*/ |
306
|
|
|
public function getHeaderStockMappings() |
307
|
|
|
{ |
308
|
|
|
return $this->headerStockMappings; |
309
|
|
|
} |
310
|
|
|
|
311
|
|
|
/** |
312
|
|
|
* Return's mapping for the supported backend types (for the product entity) => persist methods. |
313
|
|
|
* |
314
|
|
|
* @return array The mapping for the supported backend types |
315
|
|
|
*/ |
316
|
|
|
public function getBackendTypes() |
317
|
|
|
{ |
318
|
|
|
return $this->backendTypes; |
319
|
|
|
} |
320
|
|
|
|
321
|
|
|
/** |
322
|
|
|
* Return's the artefacts for post-processing. |
323
|
|
|
* |
324
|
|
|
* @return array The artefacts |
325
|
|
|
*/ |
326
|
|
|
public function getArtefacts() |
327
|
|
|
{ |
328
|
|
|
return $this->artefacs; |
329
|
|
|
} |
330
|
|
|
|
331
|
|
|
/** |
332
|
|
|
* Return's the visibility key for the passed visibility string. |
333
|
|
|
* |
334
|
|
|
* @param string $visibility The visibility string the return the key for |
335
|
|
|
* |
336
|
|
|
* @return integer The requested visibility key |
337
|
|
|
* @throws \Exception Is thrown, if the requested visibility is not available |
338
|
|
|
*/ |
339
|
|
|
public function getVisibilityIdByValue($visibility) |
340
|
|
|
{ |
341
|
|
|
|
342
|
|
|
// query whether or not, the requested visibility is available |
343
|
|
|
if (isset($this->availableVisibilities[$visibility])) { |
344
|
|
|
return $this->availableVisibilities[$visibility]; |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
// throw an exception, if not |
348
|
|
|
throw new \Exception(sprintf('Found invalid visibility %s', $visibility)); |
349
|
|
|
} |
350
|
|
|
|
351
|
|
|
/** |
352
|
|
|
* Map the passed attribute code, if a header mapping exists and return the |
353
|
|
|
* mapped mapping. |
354
|
|
|
* |
355
|
|
|
* @param string $attributeCode The attribute code to map |
356
|
|
|
* |
357
|
|
|
* @return string The mapped attribute code, or the original one |
358
|
|
|
*/ |
359
|
|
|
public function mapAttributeCodeByHeaderMapping($attributeCode) |
360
|
|
|
{ |
361
|
|
|
|
362
|
|
|
// query weather or not we've a mapping, if yes, map the attribute code |
363
|
|
|
if (isset($this->headerMappings[$attributeCode])) { |
364
|
|
|
$attributeCode = $this->headerMappings[$attributeCode]; |
365
|
|
|
} |
366
|
|
|
|
367
|
|
|
// return the (mapped) attribute code |
368
|
|
|
return $attributeCode; |
369
|
|
|
} |
370
|
|
|
|
371
|
|
|
/** |
372
|
|
|
* Add the passed product type artefacts to the product with the |
373
|
|
|
* last entity ID. |
374
|
|
|
* |
375
|
|
|
* @param string $type The artefact type, e. g. configurable |
376
|
|
|
* @param array $artefacts The product type artefacts |
377
|
|
|
* |
378
|
|
|
* @return void |
379
|
|
|
* @uses \TechDivision\Import\Product\Subjects\BunchSubject::getLastEntityId() |
380
|
|
|
*/ |
381
|
|
|
public function addArtefacts($type, array $artefacts) |
382
|
|
|
{ |
383
|
|
|
|
384
|
|
|
// query whether or not, any artefacts are available |
385
|
|
|
if (sizeof($artefacts) === 0) { |
386
|
|
|
return; |
387
|
|
|
} |
388
|
|
|
|
389
|
|
|
// append the artefacts to the stack |
390
|
|
|
$this->artefacs[$type][$this->getLastEntityId()][] = $artefacts; |
391
|
|
|
} |
392
|
|
|
|
393
|
|
|
/** |
394
|
|
|
* Add the passed SKU => entity ID mapping. |
395
|
|
|
* |
396
|
|
|
* @param string $sku The SKU |
397
|
|
|
* |
398
|
|
|
* @return void |
399
|
|
|
* @uses \Import\Csv\Actions\ProductImportBunchAction::getLastEntityId() |
400
|
|
|
*/ |
401
|
|
|
public function addSkuEntityIdMapping($sku) |
402
|
|
|
{ |
403
|
|
|
$this->skuEntityIdMapping[$sku] = $this->getLastEntityId(); |
404
|
|
|
} |
405
|
|
|
|
406
|
|
|
/** |
407
|
|
|
* Add the passed category ID to the product's category list. |
408
|
|
|
* |
409
|
|
|
* @param integer $categoryId The category ID to add |
410
|
|
|
* |
411
|
|
|
* @return void |
412
|
|
|
*/ |
413
|
|
|
public function addProductCategoryId($categoryId) |
414
|
|
|
{ |
415
|
|
|
$this->productCategoryIds[$this->getLastEntityId()][$categoryId] = $this->getLastEntityId(); |
416
|
|
|
} |
417
|
|
|
|
418
|
|
|
/** |
419
|
|
|
* Return's the list with category IDs the product is related with. |
420
|
|
|
* |
421
|
|
|
* @return array The product's category IDs |
422
|
|
|
*/ |
423
|
|
|
public function getProductCategoryIds() |
424
|
|
|
{ |
425
|
|
|
|
426
|
|
|
// initialize the array with the product's category IDs |
427
|
|
|
$categoryIds = array(); |
428
|
|
|
|
429
|
|
|
// query whether or not category IDs are available for the actual product entity |
430
|
|
|
if (isset($this->productCategoryIds[$lastEntityId = $this->getLastEntityId()])) { |
431
|
|
|
$categoryIds = $this->productCategoryIds[$lastEntityId]; |
432
|
|
|
} |
433
|
|
|
|
434
|
|
|
// return the array with the product's category IDs |
435
|
|
|
return $categoryIds; |
436
|
|
|
} |
437
|
|
|
|
438
|
|
|
/** |
439
|
|
|
* Return's the attribute option value with the passed value and store ID. |
440
|
|
|
* |
441
|
|
|
* @param mixed $value The option value |
442
|
|
|
* @param integer $storeId The ID of the store |
443
|
|
|
* |
444
|
|
|
* @return array|boolean The attribute option value instance |
445
|
|
|
*/ |
446
|
|
|
public function getEavAttributeOptionValueByOptionValueAndStoreId($value, $storeId) |
447
|
|
|
{ |
448
|
|
|
return $this->getProductProcessor()->getEavAttributeOptionValueByOptionValueAndStoreId($value, $storeId); |
449
|
|
|
} |
450
|
|
|
|
451
|
|
|
/** |
452
|
|
|
* Return's the URL rewrites for the passed URL entity type and ID. |
453
|
|
|
* |
454
|
|
|
* @param string $entityType The entity type to load the URL rewrites for |
455
|
|
|
* @param integer $entityId The entity ID to laod the rewrites for |
456
|
|
|
* |
457
|
|
|
* @return array The URL rewrites |
458
|
|
|
*/ |
459
|
1 |
|
public function getUrlRewritesByEntityTypeAndEntityId($entityType, $entityId) |
460
|
|
|
{ |
461
|
1 |
|
return $this->getProductProcessor()->getUrlRewritesByEntityTypeAndEntityId($entityType, $entityId); |
462
|
|
|
} |
463
|
|
|
|
464
|
|
|
/** |
465
|
|
|
* Load's and return's the product with the passed SKU. |
466
|
|
|
* |
467
|
|
|
* @param string $sku The SKU of the product to load |
468
|
|
|
* |
469
|
|
|
* @return array The product |
470
|
|
|
*/ |
471
|
|
|
public function loadProduct($sku) |
472
|
|
|
{ |
473
|
|
|
return $this->getProductProcessor()->loadProduct($sku); |
474
|
|
|
} |
475
|
|
|
|
476
|
|
|
/** |
477
|
|
|
* Load's and return's the product website relation with the passed product and website ID. |
478
|
|
|
* |
479
|
|
|
* @param string $productId The product ID of the relation |
480
|
|
|
* @param string $websiteId The website ID of the relation |
481
|
|
|
* |
482
|
|
|
* @return array The product website |
483
|
|
|
*/ |
484
|
|
|
public function loadProductWebsite($productId, $websiteId) |
485
|
|
|
{ |
486
|
|
|
return $this->getProductProcessor()->loadProductWebsite($productId, $websiteId); |
487
|
|
|
} |
488
|
|
|
|
489
|
|
|
/** |
490
|
|
|
* Return's the category product relation with the passed category/product ID. |
491
|
|
|
* |
492
|
|
|
* @param integer $categoryId The category ID of the category product relation to return |
493
|
|
|
* @param integer $productId The product ID of the category product relation to return |
494
|
|
|
* |
495
|
|
|
* @return array The category product relation |
496
|
|
|
*/ |
497
|
|
|
public function loadCategoryProduct($categoryId, $productId) |
498
|
|
|
{ |
499
|
|
|
return $this->getProductProcessor()->loadCategoryProduct($categoryId, $productId); |
500
|
|
|
} |
501
|
|
|
|
502
|
|
|
/** |
503
|
|
|
* Load's and return's the stock status with the passed product/website/stock ID. |
504
|
|
|
* |
505
|
|
|
* @param integer $productId The product ID of the stock status to load |
506
|
|
|
* @param integer $websiteId The website ID of the stock status to load |
507
|
|
|
* @param integer $stockId The stock ID of the stock status to load |
508
|
|
|
* |
509
|
|
|
* @return array The stock status |
510
|
|
|
*/ |
511
|
|
|
public function loadStockStatus($productId, $websiteId, $stockId) |
512
|
|
|
{ |
513
|
|
|
return $this->getProductProcessor()->loadStockStatus($productId, $websiteId, $stockId); |
514
|
|
|
} |
515
|
|
|
|
516
|
|
|
/** |
517
|
|
|
* Load's and return's the stock status with the passed product/website/stock ID. |
518
|
|
|
* |
519
|
|
|
* @param integer $productId The product ID of the stock item to load |
520
|
|
|
* @param integer $websiteId The website ID of the stock item to load |
521
|
|
|
* @param integer $stockId The stock ID of the stock item to load |
522
|
|
|
* |
523
|
|
|
* @return array The stock item |
524
|
|
|
*/ |
525
|
|
|
public function loadStockItem($productId, $websiteId, $stockId) |
526
|
|
|
{ |
527
|
|
|
return $this->getProductProcessor()->loadStockItem($productId, $websiteId, $stockId); |
528
|
|
|
} |
529
|
|
|
|
530
|
|
|
/** |
531
|
|
|
* Load's and return's the datetime attribute with the passed entity/attribute/store ID. |
532
|
|
|
* |
533
|
|
|
* @param integer $entityId The entity ID of the attribute |
534
|
|
|
* @param integer $attributeId The attribute ID of the attribute |
535
|
|
|
* @param integer $storeId The store ID of the attribute |
536
|
|
|
* |
537
|
|
|
* @return array|null The datetime attribute |
538
|
|
|
*/ |
539
|
|
|
public function loadProductDatetimeAttribute($entityId, $attributeId, $storeId) |
540
|
|
|
{ |
541
|
|
|
return $this->getProductProcessor()->loadProductDatetimeAttribute($entityId, $attributeId, $storeId); |
542
|
|
|
} |
543
|
|
|
|
544
|
|
|
/** |
545
|
|
|
* Load's and return's the decimal attribute with the passed entity/attribute/store ID. |
546
|
|
|
* |
547
|
|
|
* @param integer $entityId The entity ID of the attribute |
548
|
|
|
* @param integer $attributeId The attribute ID of the attribute |
549
|
|
|
* @param integer $storeId The store ID of the attribute |
550
|
|
|
* |
551
|
|
|
* @return array|null The decimal attribute |
552
|
|
|
*/ |
553
|
|
|
public function loadProductDecimalAttribute($entityId, $attributeId, $storeId) |
554
|
|
|
{ |
555
|
|
|
return $this->getProductProcessor()->loadProductDecimalAttribute($entityId, $attributeId, $storeId); |
556
|
|
|
} |
557
|
|
|
|
558
|
|
|
/** |
559
|
|
|
* Load's and return's the integer attribute with the passed entity/attribute/store ID. |
560
|
|
|
* |
561
|
|
|
* @param integer $entityId The entity ID of the attribute |
562
|
|
|
* @param integer $attributeId The attribute ID of the attribute |
563
|
|
|
* @param integer $storeId The store ID of the attribute |
564
|
|
|
* |
565
|
|
|
* @return array|null The integer attribute |
566
|
|
|
*/ |
567
|
|
|
public function loadProductIntAttribute($entityId, $attributeId, $storeId) |
568
|
|
|
{ |
569
|
|
|
return $this->getProductProcessor()->loadProductIntAttribute($entityId, $attributeId, $storeId); |
570
|
|
|
} |
571
|
|
|
|
572
|
|
|
/** |
573
|
|
|
* Load's and return's the text attribute with the passed entity/attribute/store ID. |
574
|
|
|
* |
575
|
|
|
* @param integer $entityId The entity ID of the attribute |
576
|
|
|
* @param integer $attributeId The attribute ID of the attribute |
577
|
|
|
* @param integer $storeId The store ID of the attribute |
578
|
|
|
* |
579
|
|
|
* @return array|null The text attribute |
580
|
|
|
*/ |
581
|
|
|
public function loadProductTextAttribute($entityId, $attributeId, $storeId) |
582
|
|
|
{ |
583
|
|
|
return $this->getProductProcessor()->loadProductTextAttribute($entityId, $attributeId, $storeId); |
584
|
|
|
} |
585
|
|
|
|
586
|
|
|
/** |
587
|
|
|
* Load's and return's the varchar attribute with the passed entity/attribute/store ID. |
588
|
|
|
* |
589
|
|
|
* @param integer $entityId The entity ID of the attribute |
590
|
|
|
* @param integer $attributeId The attribute ID of the attribute |
591
|
|
|
* @param integer $storeId The store ID of the attribute |
592
|
|
|
* |
593
|
|
|
* @return array|null The varchar attribute |
594
|
|
|
*/ |
595
|
|
|
public function loadProductVarcharAttribute($entityId, $attributeId, $storeId) |
596
|
|
|
{ |
597
|
|
|
return $this->getProductProcessor()->loadProductVarcharAttribute($entityId, $attributeId, $storeId); |
598
|
|
|
} |
599
|
|
|
|
600
|
|
|
/** |
601
|
|
|
* Persist's the passed product data and return's the ID. |
602
|
|
|
* |
603
|
|
|
* @param array $product The product data to persist |
604
|
|
|
* |
605
|
|
|
* @return string The ID of the persisted entity |
606
|
|
|
*/ |
607
|
|
|
public function persistProduct($product) |
608
|
|
|
{ |
609
|
|
|
return $this->getProductProcessor()->persistProduct($product); |
610
|
|
|
} |
611
|
|
|
|
612
|
|
|
/** |
613
|
|
|
* Persist's the passed product varchar attribute. |
614
|
|
|
* |
615
|
|
|
* @param array $attribute The attribute to persist |
616
|
|
|
* |
617
|
|
|
* @return void |
618
|
|
|
*/ |
619
|
|
|
public function persistProductVarcharAttribute($attribute) |
620
|
|
|
{ |
621
|
|
|
$this->getProductProcessor()->persistProductVarcharAttribute($attribute); |
622
|
|
|
} |
623
|
|
|
|
624
|
|
|
/** |
625
|
|
|
* Persist's the passed product integer attribute. |
626
|
|
|
* |
627
|
|
|
* @param array $attribute The attribute to persist |
628
|
|
|
* |
629
|
|
|
* @return void |
630
|
|
|
*/ |
631
|
|
|
public function persistProductIntAttribute($attribute) |
632
|
|
|
{ |
633
|
|
|
$this->getProductProcessor()->persistProductIntAttribute($attribute); |
634
|
|
|
} |
635
|
|
|
|
636
|
|
|
/** |
637
|
|
|
* Persist's the passed product decimal attribute. |
638
|
|
|
* |
639
|
|
|
* @param array $attribute The attribute to persist |
640
|
|
|
* |
641
|
|
|
* @return void |
642
|
|
|
*/ |
643
|
|
|
public function persistProductDecimalAttribute($attribute) |
644
|
|
|
{ |
645
|
|
|
$this->getProductProcessor()->persistProductDecimalAttribute($attribute); |
646
|
|
|
} |
647
|
|
|
|
648
|
|
|
/** |
649
|
|
|
* Persist's the passed product datetime attribute. |
650
|
|
|
* |
651
|
|
|
* @param array $attribute The attribute to persist |
652
|
|
|
* |
653
|
|
|
* @return void |
654
|
|
|
*/ |
655
|
|
|
public function persistProductDatetimeAttribute($attribute) |
656
|
|
|
{ |
657
|
|
|
$this->getProductProcessor()->persistProductDatetimeAttribute($attribute); |
658
|
|
|
} |
659
|
|
|
|
660
|
|
|
/** |
661
|
|
|
* Persist's the passed product text attribute. |
662
|
|
|
* |
663
|
|
|
* @param array $attribute The attribute to persist |
664
|
|
|
* |
665
|
|
|
* @return void |
666
|
|
|
*/ |
667
|
|
|
public function persistProductTextAttribute($attribute) |
668
|
|
|
{ |
669
|
|
|
$this->getProductProcessor()->persistProductTextAttribute($attribute); |
670
|
|
|
} |
671
|
|
|
|
672
|
|
|
/** |
673
|
|
|
* Persist's the passed product website data and return's the ID. |
674
|
|
|
* |
675
|
|
|
* @param array $productWebsite The product website data to persist |
676
|
|
|
* |
677
|
|
|
* @return void |
678
|
|
|
*/ |
679
|
|
|
public function persistProductWebsite($productWebsite) |
680
|
|
|
{ |
681
|
|
|
$this->getProductProcessor()->persistProductWebsite($productWebsite); |
682
|
|
|
} |
683
|
|
|
|
684
|
|
|
/** |
685
|
|
|
* Persist's the passed category product relation. |
686
|
|
|
* |
687
|
|
|
* @param array $categoryProduct The category product relation to persist |
688
|
|
|
* |
689
|
|
|
* @return void |
690
|
|
|
*/ |
691
|
|
|
public function persistCategoryProduct($categoryProduct) |
692
|
|
|
{ |
693
|
|
|
$this->getProductProcessor()->persistCategoryProduct($categoryProduct); |
694
|
|
|
} |
695
|
|
|
|
696
|
|
|
/** |
697
|
|
|
* Persist's the passed stock item data and return's the ID. |
698
|
|
|
* |
699
|
|
|
* @param array $stockItem The stock item data to persist |
700
|
|
|
* |
701
|
|
|
* @return void |
702
|
|
|
*/ |
703
|
|
|
public function persistStockItem($stockItem) |
704
|
|
|
{ |
705
|
|
|
$this->getProductProcessor()->persistStockItem($stockItem); |
706
|
|
|
} |
707
|
|
|
|
708
|
|
|
/** |
709
|
|
|
* Persist's the passed stock status data and return's the ID. |
710
|
|
|
* |
711
|
|
|
* @param array $stockStatus The stock status data to persist |
712
|
|
|
* |
713
|
|
|
* @return void |
714
|
|
|
*/ |
715
|
|
|
public function persistStockStatus($stockStatus) |
716
|
|
|
{ |
717
|
|
|
$this->getProductProcessor()->persistStockStatus($stockStatus); |
718
|
|
|
} |
719
|
|
|
|
720
|
|
|
/** |
721
|
|
|
* Persist's the URL write with the passed data. |
722
|
|
|
* |
723
|
|
|
* @param array $row The URL rewrite to persist |
724
|
|
|
* |
725
|
|
|
* @return void |
726
|
|
|
*/ |
727
|
1 |
|
public function persistUrlRewrite($row) |
728
|
|
|
{ |
729
|
1 |
|
$this->getProductProcessor()->persistUrlRewrite($row); |
730
|
1 |
|
} |
731
|
|
|
|
732
|
|
|
/** |
733
|
|
|
* Delete's the entity with the passed attributes. |
734
|
|
|
* |
735
|
|
|
* @param array $row The attributes of the entity to delete |
736
|
|
|
* @param string|null $name The name of the prepared statement that has to be executed |
737
|
|
|
* |
738
|
|
|
* @return void |
739
|
|
|
*/ |
740
|
|
|
public function deleteProduct($row, $name = null) |
741
|
|
|
{ |
742
|
|
|
$this->getProductProcessor()->deleteProduct($row, $name); |
743
|
|
|
} |
744
|
|
|
|
745
|
|
|
/** |
746
|
|
|
* Delete's the URL rewrite(s) with the passed attributes. |
747
|
|
|
* |
748
|
|
|
* @param array $row The attributes of the entity to delete |
749
|
|
|
* @param string|null $name The name of the prepared statement that has to be executed |
750
|
|
|
* |
751
|
|
|
* @return void |
752
|
|
|
*/ |
753
|
1 |
|
public function deleteUrlRewrite($row, $name = null) |
754
|
|
|
{ |
755
|
1 |
|
$this->getProductProcessor()->deleteUrlRewrite($row, $name); |
756
|
1 |
|
} |
757
|
|
|
|
758
|
|
|
/** |
759
|
|
|
* Delete's the stock item(s) with the passed attributes. |
760
|
|
|
* |
761
|
|
|
* @param array $row The attributes of the entity to delete |
762
|
|
|
* @param string|null $name The name of the prepared statement that has to be executed |
763
|
|
|
* |
764
|
|
|
* @return void |
765
|
|
|
*/ |
766
|
|
|
public function deleteStockItem($row, $name = null) |
767
|
|
|
{ |
768
|
|
|
$this->getProductProcessor()->deleteStockItem($row, $name); |
769
|
|
|
} |
770
|
|
|
|
771
|
|
|
/** |
772
|
|
|
* Delete's the stock status with the passed attributes. |
773
|
|
|
* |
774
|
|
|
* @param array $row The attributes of the entity to delete |
775
|
|
|
* @param string|null $name The name of the prepared statement that has to be executed |
776
|
|
|
* |
777
|
|
|
* @return void |
778
|
|
|
*/ |
779
|
|
|
public function deleteStockStatus($row, $name = null) |
780
|
|
|
{ |
781
|
|
|
$this->getProductProcessor()->deleteStockStatus($row, $name); |
782
|
|
|
} |
783
|
|
|
|
784
|
|
|
/** |
785
|
|
|
* Delete's the product website relations with the passed attributes. |
786
|
|
|
* |
787
|
|
|
* @param array $row The attributes of the entity to delete |
788
|
|
|
* @param string|null $name The name of the prepared statement that has to be executed |
789
|
|
|
* |
790
|
|
|
* @return void |
791
|
|
|
*/ |
792
|
|
|
public function deleteProductWebsite($row, $name = null) |
793
|
|
|
{ |
794
|
|
|
$this->getProductProcessor()->deleteProductWebsite($row, $name); |
795
|
|
|
} |
796
|
|
|
|
797
|
|
|
/** |
798
|
|
|
* Delete's the category product relations with the passed attributes. |
799
|
|
|
* |
800
|
|
|
* @param array $row The attributes of the entity to delete |
801
|
|
|
* @param string|null $name The name of the prepared statement that has to be executed |
802
|
|
|
* |
803
|
|
|
* @return void |
804
|
|
|
*/ |
805
|
|
|
public function deleteCategoryProduct($row, $name = null) |
806
|
|
|
{ |
807
|
|
|
$this->getProductProcessor()->deleteCategoryProduct($row, $name); |
808
|
|
|
} |
809
|
|
|
} |
810
|
|
|
|