Completed
Push — master ( 7bba9a...df8d00 )
by Tim
9s
created

BunchSubject   F

Complexity

Total Complexity 62

Size/Duplication

Total Lines 788
Duplicated Lines 2.28 %

Coupling/Cohesion

Components 4
Dependencies 5

Test Coverage

Coverage 11.88%

Importance

Changes 0
Metric Value
wmc 62
lcom 4
cbo 5
dl 18
loc 788
ccs 19
cts 160
cp 0.1188
rs 3.0769
c 0
b 0
f 0

45 Methods

Rating   Name   Duplication   Size   Complexity  
A setAttributeSet() 0 4 1
A getAttributeSet() 0 4 1
A tearDown() 0 18 1
B exportArtefacts() 0 32 5
A getTargetDir() 0 4 1
C getExportConfig() 0 39 7
A castValueByBackendType() 0 21 4
A getHeaderStockMappings() 0 4 1
A getBackendTypes() 0 4 1
A getArtefacts() 0 4 1
A getVisibilityIdByValue() 18 18 2
A mapAttributeCodeByHeaderMapping() 0 11 2
A addArtefacts() 0 11 2
A addSkuEntityIdMapping() 0 4 1
A addProductCategoryId() 0 4 1
A getProductCategoryIds() 0 14 2
A getEavAttributeOptionValueByOptionValueAndStoreId() 0 4 1
A getUrlRewritesByEntityTypeAndEntityId() 0 4 1
A loadProduct() 0 4 1
A loadProductWebsite() 0 4 1
A loadCategoryProduct() 0 4 1
A loadStockStatus() 0 4 1
A loadStockItem() 0 4 1
A loadProductDatetimeAttribute() 0 4 1
A loadProductDecimalAttribute() 0 4 1
A loadProductIntAttribute() 0 4 1
A loadProductTextAttribute() 0 4 1
A loadProductVarcharAttribute() 0 4 1
A persistProduct() 0 4 1
A persistProductVarcharAttribute() 0 4 1
A persistProductIntAttribute() 0 4 1
A persistProductDecimalAttribute() 0 4 1
A persistProductDatetimeAttribute() 0 4 1
A persistProductTextAttribute() 0 4 1
A persistProductWebsite() 0 4 1
A persistCategoryProduct() 0 4 1
A persistStockItem() 0 4 1
A persistStockStatus() 0 4 1
A persistUrlRewrite() 0 4 1
A deleteProduct() 0 4 1
A deleteUrlRewrite() 0 4 1
A deleteStockItem() 0 4 1
A deleteStockStatus() 0 4 1
A deleteProductWebsite() 0 4 1
A deleteCategoryProduct() 0 4 1

How to fix   Duplicated Code    Complexity   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

Complex Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like BunchSubject often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use BunchSubject, and based on these observations, apply Extract Interface, too.

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
        'shipment_type' => 'bundle_shipment_type'
71
    );
72
73
    /**
74
     * Mappings for the table column => CSV column header.
75
     *
76
     * @var array
77
     */
78
    protected $headerStockMappings = array(
79
        'qty'                         => array('qty', 'float'),
80
        'min_qty'                     => array('out_of_stock_qty', 'float'),
81
        'use_config_min_qty'          => array('use_config_min_qty', 'int'),
82
        'is_qty_decimal'              => array('is_qty_decimal', 'int'),
83
        'backorders'                  => array('allow_backorders', 'int'),
84
        'use_config_backorders'       => array('use_config_backorders', 'int'),
85
        'min_sale_qty'                => array('min_cart_qty', 'float'),
86
        'use_config_min_sale_qty'     => array('use_config_min_sale_qty', 'int'),
87
        'max_sale_qty'                => array('max_cart_qty', 'float'),
88
        'use_config_max_sale_qty'     => array('use_config_max_sale_qty', 'int'),
89
        'is_in_stock'                 => array('is_in_stock', 'int'),
90
        'notify_stock_qty'            => array('notify_on_stock_below', 'float'),
91
        'use_config_notify_stock_qty' => array('use_config_notify_stock_qty', 'int'),
92
        'manage_stock'                => array('manage_stock', 'int'),
93
        'use_config_manage_stock'     => array('use_config_manage_stock', 'int'),
94
        'use_config_qty_increments'   => array('use_config_qty_increments', 'int'),
95
        'qty_increments'              => array('qty_increments', 'float'),
96
        'use_config_enable_qty_inc'   => array('use_config_enable_qty_inc', 'int'),
97
        'enable_qty_increments'       => array('enable_qty_increments', 'int'),
98
        'is_decimal_divided'          => array('is_decimal_divided', 'int'),
99
    );
100
101
    /**
102
     * The array with the available visibility keys.
103
     *
104
     * @var array
105
     */
106
    protected $availableVisibilities = array(
107
        'Not Visible Individually' => VisibilityKeys::VISIBILITY_NOT_VISIBLE,
108
        'Catalog'                  => VisibilityKeys::VISIBILITY_IN_CATALOG,
109
        'Search'                   => VisibilityKeys::VISIBILITY_IN_SEARCH,
110
        'Catalog, Search'          => VisibilityKeys::VISIBILITY_BOTH
111
    );
112
113
    /**
114
     * The attribute set of the product that has to be created.
115
     *
116
     * @var array
117
     */
118
    protected $attributeSet = array();
119
120
    /**
121
     * The array containing the data for product type configuration (configurables, bundles, etc).
122
     *
123
     * @var array
124
     */
125
    protected $artefacs = array();
126
127
    /**
128
     * The mapping for the SKUs to the created entity IDs.
129
     *
130
     * @var array
131
     */
132
    protected $skuEntityIdMapping = array();
133
134
    /**
135
     * The category IDs the product is related with.
136
     *
137
     * @var array
138
     */
139
    protected $productCategoryIds = array();
140
141
    /**
142
     * Set's the attribute set of the product that has to be created.
143
     *
144
     * @param array $attributeSet The attribute set
145
     *
146
     * @return void
147
     */
148 1
    public function setAttributeSet(array $attributeSet)
149
    {
150 1
        $this->attributeSet = $attributeSet;
151 1
    }
152
153
    /**
154
     * Return's the attribute set of the product that has to be created.
155
     *
156
     * @return array The attribute set
157
     */
158
    public function getAttributeSet()
159
    {
160
        return $this->attributeSet;
161
    }
162
163
    /**
164
     * Clean up the global data after importing the bunch.
165
     *
166
     * @return void
167
     */
168
    public function tearDown()
169
    {
170
171
        // invoke parent method
172
        parent::tearDown();
173
174
        // export the artefacts
175
        $this->exportArtefacts();
176
177
        // load the registry processor
178
        $registryProcessor = $this->getRegistryProcessor();
179
180
        // update the status with the SKU => entity ID mapping
181
        $registryProcessor->mergeAttributesRecursive(
182
            $this->getSerial(),
183
            array(RegistryKeys::SKU_ENTITY_ID_MAPPING => $this->skuEntityIdMapping)
184
        );
185
    }
186
187
    /**
188
     * Export's the artefacts to CSV files.
189
     *
190
     * @return void
191
     */
192
    protected function exportArtefacts()
193
    {
194
195
        // load the target directory and the actual timestamp
196
        $targetDir = $this->getTargetDir();
197
        $timestamp = date('Ymd-His');
198
199
        // iterate over the artefacts and export them
200
        foreach ($this->getArtefacts() as $artefactType => $artefacts) {
201
            // initialize the bunch and the exporter
202
            $bunch = array();
203
            $exporter = new Exporter($this->getExportConfig());
204
205
            // iterate over the artefact types artefacts
206
            foreach ($artefacts as $entityArtefacts) {
207
                // set the bunch header and append the artefact data
208
                if (sizeof($bunch) === 0) {
209
                    $first = reset($entityArtefacts);
210
                    $second = reset($first);
211
                    $bunch[] = array_keys($second);
212
                }
213
214
                // export the artefacts
215
                foreach ($entityArtefacts as $entityArtefact) {
216
                    $bunch = array_merge($bunch, $entityArtefact);
217
                }
218
            }
219
220
            // export the artefact (bunch)
221
            $exporter->export(sprintf('%s/%s-%s_01.csv', $targetDir, $artefactType, $timestamp), $bunch);
222
        }
223
    }
224
225
    /**
226
     * Return's the target directory for the artefact export.
227
     *
228
     * @return string The target directory for the artefact export
229
     */
230
    protected function getTargetDir()
231
    {
232
        return $this->getNewSourceDir();
0 ignored issues
show
Bug introduced by
The method getNewSourceDir() does not seem to exist on object<TechDivision\Impo...\Subjects\BunchSubject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
233
    }
234
235
    /**
236
     * Initialize and return the exporter configuration.
237
     *
238
     * @return \Goodby\CSV\Export\Standard\ExporterConfig The exporter configuration
239
     */
240
    protected function getExportConfig()
241
    {
242
243
        // initialize the lexer configuration
244
        $config = new ExporterConfig();
245
246
        // query whether or not a delimiter character has been configured
247
        if ($delimiter = $this->getConfiguration()->getDelimiter()) {
248
            $config->setDelimiter($delimiter);
249
        }
250
251
        // query whether or not a custom escape character has been configured
252
        if ($escape = $this->getConfiguration()->getEscape()) {
253
            $config->setEscape($escape);
254
        }
255
256
        // query whether or not a custom enclosure character has been configured
257
        if ($enclosure = $this->getConfiguration()->getEnclosure()) {
258
            $config->setEnclosure($enclosure);
259
        }
260
261
        // query whether or not a custom source charset has been configured
262
        if ($fromCharset = $this->getConfiguration()->getFromCharset()) {
263
            $config->setFromCharset($fromCharset);
264
        }
265
266
        // query whether or not a custom target charset has been configured
267
        if ($toCharset = $this->getConfiguration()->getToCharset()) {
268
            $config->setToCharset($toCharset);
269
        }
270
271
        // query whether or not a custom file mode has been configured
272
        if ($fileMode = $this->getConfiguration()->getFileMode()) {
273
            $config->setFileMode($fileMode);
274
        }
275
276
        // return the lexer configuratio
277
        return $config;
278
    }
279
280
    /**
281
     * Cast's the passed value based on the backend type information.
282
     *
283
     * @param string $backendType The backend type to cast to
284
     * @param mixed  $value       The value to be casted
285
     *
286
     * @return mixed The casted value
287
     */
288 1
    public function castValueByBackendType($backendType, $value)
289
    {
290
291
        // cast the value to a valid timestamp
292 1
        if ($backendType === 'datetime') {
293
            return \DateTime::createFromFormat($this->getSourceDateFormat(), $value)->format('Y-m-d H:i:s');
294
        }
295
296
        // cast the value to a float value
297 1
        if ($backendType === 'float') {
298 1
            return (float) $value;
299
        }
300
301
        // cast the value to an integer
302 1
        if ($backendType === 'int') {
303 1
            return (int) $value;
304
        }
305
306
        // we don't need to cast strings
307
        return $value;
308
    }
309
310
    /**
311
     * Return's the mappings for the table column => CSV column header.
312
     *
313
     * @return array The header stock mappings
314
     */
315 1
    public function getHeaderStockMappings()
316
    {
317 1
        return $this->headerStockMappings;
318
    }
319
320
    /**
321
     * Return's mapping for the supported backend types (for the product entity) => persist methods.
322
     *
323
     * @return array The mapping for the supported backend types
324
     */
325
    public function getBackendTypes()
326
    {
327
        return $this->backendTypes;
328
    }
329
330
    /**
331
     * Return's the artefacts for post-processing.
332
     *
333
     * @return array The artefacts
334
     */
335
    public function getArtefacts()
336
    {
337
        return $this->artefacs;
338
    }
339
340
    /**
341
     * Return's the visibility key for the passed visibility string.
342
     *
343
     * @param string $visibility The visibility string to return the key for
344
     *
345
     * @return integer The requested visibility key
346
     * @throws \Exception Is thrown, if the requested visibility is not available
347
     */
348 View Code Duplication
    public function getVisibilityIdByValue($visibility)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
349
    {
350
351
        // query whether or not, the requested visibility is available
352
        if (isset($this->availableVisibilities[$visibility])) {
353
            return $this->availableVisibilities[$visibility];
354
        }
355
356
        // throw an exception, if not
357
        throw new \Exception(
358
            sprintf(
359
                'Found invalid visibility %s in file %s on line %d',
360
                $visibility,
361
                $this->getFilename(),
362
                $this->getLineNumber()
0 ignored issues
show
Bug introduced by
The method getLineNumber() does not seem to exist on object<TechDivision\Impo...\Subjects\BunchSubject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
363
            )
364
        );
365
    }
366
367
    /**
368
     * Map the passed attribute code, if a header mapping exists and return the
369
     * mapped mapping.
370
     *
371
     * @param string $attributeCode The attribute code to map
372
     *
373
     * @return string The mapped attribute code, or the original one
374
     */
375
    public function mapAttributeCodeByHeaderMapping($attributeCode)
376
    {
377
378
        // query weather or not we've a mapping, if yes, map the attribute code
379
        if (isset($this->headerMappings[$attributeCode])) {
380
            $attributeCode = $this->headerMappings[$attributeCode];
381
        }
382
383
        // return the (mapped) attribute code
384
        return $attributeCode;
385
    }
386
387
    /**
388
     * Add the passed product type artefacts to the product with the
389
     * last entity ID.
390
     *
391
     * @param string $type      The artefact type, e. g. configurable
392
     * @param array  $artefacts The product type artefacts
393
     *
394
     * @return void
395
     * @uses \TechDivision\Import\Product\Subjects\BunchSubject::getLastEntityId()
396
     */
397
    public function addArtefacts($type, array $artefacts)
398
    {
399
400
        // query whether or not, any artefacts are available
401
        if (sizeof($artefacts) === 0) {
402
            return;
403
        }
404
405
        // append the artefacts to the stack
406
        $this->artefacs[$type][$this->getLastEntityId()][] = $artefacts;
407
    }
408
409
    /**
410
     * Add the passed SKU => entity ID mapping.
411
     *
412
     * @param string $sku The SKU
413
     *
414
     * @return void
415
     * @uses \Import\Csv\Actions\ProductImportBunchAction::getLastEntityId()
416
     */
417
    public function addSkuEntityIdMapping($sku)
418
    {
419
        $this->skuEntityIdMapping[$sku] = $this->getLastEntityId();
420
    }
421
422
    /**
423
     * Add the passed category ID to the product's category list.
424
     *
425
     * @param integer $categoryId The category ID to add
426
     *
427
     * @return void
428
     */
429
    public function addProductCategoryId($categoryId)
430
    {
431
        $this->productCategoryIds[$this->getLastEntityId()][$categoryId] = $this->getLastEntityId();
432
    }
433
434
    /**
435
     * Return's the list with category IDs the product is related with.
436
     *
437
     * @return array The product's category IDs
438
     */
439
    public function getProductCategoryIds()
440
    {
441
442
        // initialize the array with the product's category IDs
443
        $categoryIds = array();
444
445
        // query whether or not category IDs are available for the actual product entity
446
        if (isset($this->productCategoryIds[$lastEntityId = $this->getLastEntityId()])) {
447
            $categoryIds = $this->productCategoryIds[$lastEntityId];
448
        }
449
450
        // return the array with the product's category IDs
451
        return $categoryIds;
452
    }
453
454
    /**
455
     * Return's the attribute option value with the passed value and store ID.
456
     *
457
     * @param mixed   $value   The option value
458
     * @param integer $storeId The ID of the store
459
     *
460
     * @return array|boolean The attribute option value instance
461
     */
462
    public function getEavAttributeOptionValueByOptionValueAndStoreId($value, $storeId)
463
    {
464
        return $this->getProductProcessor()->getEavAttributeOptionValueByOptionValueAndStoreId($value, $storeId);
465
    }
466
467
    /**
468
     * Return's the URL rewrites for the passed URL entity type and ID.
469
     *
470
     * @param string  $entityType The entity type to load the URL rewrites for
471
     * @param integer $entityId   The entity ID to laod the rewrites for
472
     *
473
     * @return array The URL rewrites
474
     */
475 1
    public function getUrlRewritesByEntityTypeAndEntityId($entityType, $entityId)
476
    {
477 1
        return $this->getProductProcessor()->getUrlRewritesByEntityTypeAndEntityId($entityType, $entityId);
478
    }
479
480
    /**
481
     * Load's and return's the product with the passed SKU.
482
     *
483
     * @param string $sku The SKU of the product to load
484
     *
485
     * @return array The product
486
     */
487
    public function loadProduct($sku)
488
    {
489
        return $this->getProductProcessor()->loadProduct($sku);
490
    }
491
492
    /**
493
     * Load's and return's the product website relation with the passed product and website ID.
494
     *
495
     * @param string $productId The product ID of the relation
496
     * @param string $websiteId The website ID of the relation
497
     *
498
     * @return array The product website
499
     */
500
    public function loadProductWebsite($productId, $websiteId)
501
    {
502
        return $this->getProductProcessor()->loadProductWebsite($productId, $websiteId);
503
    }
504
505
    /**
506
     * Return's the category product relation with the passed category/product ID.
507
     *
508
     * @param integer $categoryId The category ID of the category product relation to return
509
     * @param integer $productId  The product ID of the category product relation to return
510
     *
511
     * @return array The category product relation
512
     */
513
    public function loadCategoryProduct($categoryId, $productId)
514
    {
515
        return $this->getProductProcessor()->loadCategoryProduct($categoryId, $productId);
516
    }
517
518
    /**
519
     * Load's and return's the stock status with the passed product/website/stock ID.
520
     *
521
     * @param integer $productId The product ID of the stock status to load
522
     * @param integer $websiteId The website ID of the stock status to load
523
     * @param integer $stockId   The stock ID of the stock status to load
524
     *
525
     * @return array The stock status
526
     */
527
    public function loadStockStatus($productId, $websiteId, $stockId)
528
    {
529
        return $this->getProductProcessor()->loadStockStatus($productId, $websiteId, $stockId);
530
    }
531
532
    /**
533
     * Load's and return's the stock status with the passed product/website/stock ID.
534
     *
535
     * @param integer $productId The product ID of the stock item to load
536
     * @param integer $websiteId The website ID of the stock item to load
537
     * @param integer $stockId   The stock ID of the stock item to load
538
     *
539
     * @return array The stock item
540
     */
541
    public function loadStockItem($productId, $websiteId, $stockId)
542
    {
543
        return $this->getProductProcessor()->loadStockItem($productId, $websiteId, $stockId);
544
    }
545
546
    /**
547
     * Load's and return's the datetime attribute with the passed entity/attribute/store ID.
548
     *
549
     * @param integer $entityId    The entity ID of the attribute
550
     * @param integer $attributeId The attribute ID of the attribute
551
     * @param integer $storeId     The store ID of the attribute
552
     *
553
     * @return array|null The datetime attribute
554
     */
555
    public function loadProductDatetimeAttribute($entityId, $attributeId, $storeId)
556
    {
557
        return $this->getProductProcessor()->loadProductDatetimeAttribute($entityId, $attributeId, $storeId);
558
    }
559
560
    /**
561
     * Load's and return's the decimal attribute with the passed entity/attribute/store ID.
562
     *
563
     * @param integer $entityId    The entity ID of the attribute
564
     * @param integer $attributeId The attribute ID of the attribute
565
     * @param integer $storeId     The store ID of the attribute
566
     *
567
     * @return array|null The decimal attribute
568
     */
569
    public function loadProductDecimalAttribute($entityId, $attributeId, $storeId)
570
    {
571
        return $this->getProductProcessor()->loadProductDecimalAttribute($entityId, $attributeId, $storeId);
572
    }
573
574
    /**
575
     * Load's and return's the integer attribute with the passed entity/attribute/store ID.
576
     *
577
     * @param integer $entityId    The entity ID of the attribute
578
     * @param integer $attributeId The attribute ID of the attribute
579
     * @param integer $storeId     The store ID of the attribute
580
     *
581
     * @return array|null The integer attribute
582
     */
583
    public function loadProductIntAttribute($entityId, $attributeId, $storeId)
584
    {
585
        return $this->getProductProcessor()->loadProductIntAttribute($entityId, $attributeId, $storeId);
586
    }
587
588
    /**
589
     * Load's and return's the text attribute with the passed entity/attribute/store ID.
590
     *
591
     * @param integer $entityId    The entity ID of the attribute
592
     * @param integer $attributeId The attribute ID of the attribute
593
     * @param integer $storeId     The store ID of the attribute
594
     *
595
     * @return array|null The text attribute
596
     */
597
    public function loadProductTextAttribute($entityId, $attributeId, $storeId)
598
    {
599
        return $this->getProductProcessor()->loadProductTextAttribute($entityId, $attributeId, $storeId);
600
    }
601
602
    /**
603
     * Load's and return's the varchar attribute with the passed entity/attribute/store ID.
604
     *
605
     * @param integer $entityId    The entity ID of the attribute
606
     * @param integer $attributeId The attribute ID of the attribute
607
     * @param integer $storeId     The store ID of the attribute
608
     *
609
     * @return array|null The varchar attribute
610
     */
611
    public function loadProductVarcharAttribute($entityId, $attributeId, $storeId)
612
    {
613
        return $this->getProductProcessor()->loadProductVarcharAttribute($entityId, $attributeId, $storeId);
614
    }
615
616
    /**
617
     * Persist's the passed product data and return's the ID.
618
     *
619
     * @param array $product The product data to persist
620
     *
621
     * @return string The ID of the persisted entity
622
     */
623
    public function persistProduct($product)
624
    {
625
        return $this->getProductProcessor()->persistProduct($product);
626
    }
627
628
    /**
629
     * Persist's the passed product varchar attribute.
630
     *
631
     * @param array $attribute The attribute to persist
632
     *
633
     * @return void
634
     */
635
    public function persistProductVarcharAttribute($attribute)
636
    {
637
        $this->getProductProcessor()->persistProductVarcharAttribute($attribute);
638
    }
639
640
    /**
641
     * Persist's the passed product integer attribute.
642
     *
643
     * @param array $attribute The attribute to persist
644
     *
645
     * @return void
646
     */
647
    public function persistProductIntAttribute($attribute)
648
    {
649
        $this->getProductProcessor()->persistProductIntAttribute($attribute);
650
    }
651
652
    /**
653
     * Persist's the passed product decimal attribute.
654
     *
655
     * @param array $attribute The attribute to persist
656
     *
657
     * @return void
658
     */
659
    public function persistProductDecimalAttribute($attribute)
660
    {
661
        $this->getProductProcessor()->persistProductDecimalAttribute($attribute);
662
    }
663
664
    /**
665
     * Persist's the passed product datetime attribute.
666
     *
667
     * @param array $attribute The attribute to persist
668
     *
669
     * @return void
670
     */
671
    public function persistProductDatetimeAttribute($attribute)
672
    {
673
        $this->getProductProcessor()->persistProductDatetimeAttribute($attribute);
674
    }
675
676
    /**
677
     * Persist's the passed product text attribute.
678
     *
679
     * @param array $attribute The attribute to persist
680
     *
681
     * @return void
682
     */
683
    public function persistProductTextAttribute($attribute)
684
    {
685
        $this->getProductProcessor()->persistProductTextAttribute($attribute);
686
    }
687
688
    /**
689
     * Persist's the passed product website data and return's the ID.
690
     *
691
     * @param array $productWebsite The product website data to persist
692
     *
693
     * @return void
694
     */
695
    public function persistProductWebsite($productWebsite)
696
    {
697
        $this->getProductProcessor()->persistProductWebsite($productWebsite);
698
    }
699
700
    /**
701
     * Persist's the passed category product relation.
702
     *
703
     * @param array $categoryProduct The category product relation to persist
704
     *
705
     * @return void
706
     */
707
    public function persistCategoryProduct($categoryProduct)
708
    {
709
        $this->getProductProcessor()->persistCategoryProduct($categoryProduct);
710
    }
711
712
    /**
713
     * Persist's the passed stock item data and return's the ID.
714
     *
715
     * @param array $stockItem The stock item data to persist
716
     *
717
     * @return void
718
     */
719
    public function persistStockItem($stockItem)
720
    {
721
        $this->getProductProcessor()->persistStockItem($stockItem);
722
    }
723
724
    /**
725
     * Persist's the passed stock status data and return's the ID.
726
     *
727
     * @param array $stockStatus The stock status data to persist
728
     *
729
     * @return void
730
     */
731
    public function persistStockStatus($stockStatus)
732
    {
733
        $this->getProductProcessor()->persistStockStatus($stockStatus);
734
    }
735
736
    /**
737
     * Persist's the URL write with the passed data.
738
     *
739
     * @param array $row The URL rewrite to persist
740
     *
741
     * @return void
742
     */
743 1
    public function persistUrlRewrite($row)
744
    {
745 1
        $this->getProductProcessor()->persistUrlRewrite($row);
746 1
    }
747
748
    /**
749
     * Delete's the entity with the passed attributes.
750
     *
751
     * @param array       $row  The attributes of the entity to delete
752
     * @param string|null $name The name of the prepared statement that has to be executed
753
     *
754
     * @return void
755
     */
756
    public function deleteProduct($row, $name = null)
757
    {
758
        $this->getProductProcessor()->deleteProduct($row, $name);
759
    }
760
761
    /**
762
     * Delete's the URL rewrite(s) with the passed attributes.
763
     *
764
     * @param array       $row  The attributes of the entity to delete
765
     * @param string|null $name The name of the prepared statement that has to be executed
766
     *
767
     * @return void
768
     */
769 1
    public function deleteUrlRewrite($row, $name = null)
770
    {
771 1
        $this->getProductProcessor()->deleteUrlRewrite($row, $name);
772 1
    }
773
774
    /**
775
     * Delete's the stock item(s) with the passed attributes.
776
     *
777
     * @param array       $row  The attributes of the entity to delete
778
     * @param string|null $name The name of the prepared statement that has to be executed
779
     *
780
     * @return void
781
     */
782
    public function deleteStockItem($row, $name = null)
783
    {
784
        $this->getProductProcessor()->deleteStockItem($row, $name);
785
    }
786
787
    /**
788
     * Delete's the stock status with the passed attributes.
789
     *
790
     * @param array       $row  The attributes of the entity to delete
791
     * @param string|null $name The name of the prepared statement that has to be executed
792
     *
793
     * @return void
794
     */
795
    public function deleteStockStatus($row, $name = null)
796
    {
797
        $this->getProductProcessor()->deleteStockStatus($row, $name);
798
    }
799
800
    /**
801
     * Delete's the product website relations with the passed attributes.
802
     *
803
     * @param array       $row  The attributes of the entity to delete
804
     * @param string|null $name The name of the prepared statement that has to be executed
805
     *
806
     * @return void
807
     */
808
    public function deleteProductWebsite($row, $name = null)
809
    {
810
        $this->getProductProcessor()->deleteProductWebsite($row, $name);
811
    }
812
813
    /**
814
     * Delete's the category product relations with the passed attributes.
815
     *
816
     * @param array       $row  The attributes of the entity to delete
817
     * @param string|null $name The name of the prepared statement that has to be executed
818
     *
819
     * @return void
820
     */
821
    public function deleteCategoryProduct($row, $name = null)
822
    {
823
        $this->getProductProcessor()->deleteCategoryProduct($row, $name);
824
    }
825
}
826