Completed
Push — master ( 23587a...d53256 )
by Tim
8s
created

ProductBunchProcessor::getStockStatusAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
/**
4
 * TechDivision\Import\Product\Services\ProductBunchProcessor
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\Services;
22
23
use TechDivision\Import\Actions\UrlRewriteAction;
24
use TechDivision\Import\Connection\ConnectionInterface;
25
use TechDivision\Import\Product\Utils\MemberNames;
26
use TechDivision\Import\Product\Actions\CategoryProductActionInterface;
27
use TechDivision\Import\Product\Actions\ProductAction;
28
use TechDivision\Import\Product\Actions\ProductDatetimeActionInterface;
29
use TechDivision\Import\Product\Actions\ProductDecimalActionInterface;
30
use TechDivision\Import\Product\Actions\ProductIntActionInterface;
31
use TechDivision\Import\Product\Actions\ProductTextActionInterface;
32
use TechDivision\Import\Product\Actions\ProductVarcharActionInterface;
33
use TechDivision\Import\Product\Actions\ProductWebsiteActionInterface;
34
use TechDivision\Import\Product\Actions\StockItemActionInterface;
35
use TechDivision\Import\Product\Repositories\CategoryProductRepository;
36
use TechDivision\Import\Product\Repositories\ProductDatetimeRepository;
37
use TechDivision\Import\Product\Repositories\ProductDecimalRepository;
38
use TechDivision\Import\Product\Repositories\ProductIntRepository;
39
use TechDivision\Import\Product\Repositories\ProductRepository;
40
use TechDivision\Import\Product\Repositories\ProductTextRepository;
41
use TechDivision\Import\Product\Repositories\ProductVarcharRepository;
42
use TechDivision\Import\Product\Repositories\ProductWebsiteRepository;
43
use TechDivision\Import\Product\Repositories\StockItemRepository;
44
use TechDivision\Import\Repositories\EavAttributeOptionValueRepository;
45
use TechDivision\Import\Repositories\EavAttributeRepository;
46
use TechDivision\Import\Product\Assemblers\ProductAttributeAssemblerInterface;
47
48
/**
49
 * The product bunch processor implementation.
50
 *
51
 * @author    Tim Wagner <[email protected]>
52
 * @copyright 2016 TechDivision GmbH <[email protected]>
53
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
54
 * @link      https://github.com/techdivision/import-product
55
 * @link      http://www.techdivision.com
56
 */
57
class ProductBunchProcessor implements ProductBunchProcessorInterface
58
{
59
60
    /**
61
     * A PDO connection initialized with the values from the Doctrine EntityManager.
62
     *
63
     * @var \TechDivision\Import\Connection\ConnectionInterface
64
     */
65
    protected $connection;
66
67
    /**
68
     * The repository to access EAV attribute option values.
69
     *
70
     * @var \TechDivision\Import\Repositories\EavAttributeOptionValueRepository
71
     */
72
    protected $eavAttributeOptionValueRepository;
73
74
    /**
75
     * The repository to access EAV attributes.
76
     *
77
     * @var \TechDivision\Import\Repositories\EavAttributeRepository
78
     */
79
    protected $eavAttributeRepository;
80
81
    /**
82
     * The action for product CRUD methods.
83
     *
84
     * @var \TechDivision\Import\Product\Actions\ProductAction
85
     */
86
    protected $productAction;
87
88
    /**
89
     * The action for product varchar attribute CRUD methods.
90
     *
91
     * @var \TechDivision\Import\Product\Actions\ProductVarcharActionInterface
92
     */
93
    protected $productVarcharAction;
94
95
    /**
96
     * The action for product text attribute CRUD methods.
97
     *
98
     * @var \TechDivision\Import\Product\Actions\ProductTextActionInterface
99
     */
100
    protected $productTextAction;
101
102
    /**
103
     * The action for product int attribute CRUD methods.
104
     *
105
     * @var \TechDivision\Import\Product\Actions\ProductIntActionInterface
106
     */
107
    protected $productIntAction;
108
109
    /**
110
     * The action for product decimal attribute CRUD methods.
111
     *
112
     * @var \TechDivision\Import\Product\Actions\ProductDecimalActionInterface
113
     */
114
    protected $productDecimalAction;
115
116
    /**
117
     * The action for product datetime attribute CRUD methods.
118
     *
119
     * @var \TechDivision\Import\Product\Actions\ProductDatetimeActionInterface
120
     */
121
    protected $productDatetimeAction;
122
123
    /**
124
     * The action for product website CRUD methods.
125
     *
126
     * @var \TechDivision\Import\Product\Actions\ProductWebsiteActionInterface
127
     */
128
    protected $productWebsiteAction;
129
130
    /**
131
     * The action for category product relation CRUD methods.
132
     *
133
     * @var \TechDivision\Import\Product\Actions\CategoryProductActionInterface
134
     */
135
    protected $categoryProductAction;
136
137
    /**
138
     * The action for stock item CRUD methods.
139
     *
140
     * @var \TechDivision\Import\Product\Actions\StockItemActionInterface
141
     */
142
    protected $stockItemAction;
143
144
    /**
145
     * The action for URL rewrite CRUD methods.
146
     *
147
     * @var \TechDivision\Import\Actions\UrlRewriteAction
148
     */
149
    protected $urlRewriteAction;
150
151
    /**
152
     * The repository to load the products with.
153
     *
154
     * @var \TechDivision\Import\Product\Repositories\ProductRepository
155
     */
156
    protected $productRepository;
157
158
    /**
159
     * The repository to load the product website relations with.
160
     *
161
     * @var \TechDivision\Import\Product\Repositories\ProductWebsiteRepository
162
     */
163
    protected $productWebsiteRepository;
164
165
    /**
166
     * The repository to load the product datetime attribute with.
167
     *
168
     * @var \TechDivision\Import\Product\Repositories\ProductDatetimeRepository
169
     */
170
    protected $productDatetimeRepository;
171
172
    /**
173
     * The repository to load the product decimal attribute with.
174
     *
175
     * @var \TechDivision\Import\Product\Repositories\ProductDecimalRepository
176
     */
177
    protected $productDecimalRepository;
178
179
    /**
180
     * The repository to load the product integer attribute with.
181
     *
182
     * @var \TechDivision\Import\Product\Repositories\ProductIntRepository
183
     */
184
    protected $productIntRepository;
185
186
    /**
187
     * The repository to load the product text attribute with.
188
     *
189
     * @var \TechDivision\Import\Product\Repositories\ProductTextRepository
190
     */
191
    protected $productTextRepository;
192
193
    /**
194
     * The repository to load the product varchar attribute with.
195
     *
196
     * @var \TechDivision\Import\Product\Repositories\ProductVarcharRepository
197
     */
198
    protected $productVarcharRepository;
199
200
    /**
201
     * The repository to load the category product relations with.
202
     *
203
     * @var \TechDivision\Import\Product\Repositories\CategoryProductRepository
204
     */
205
    protected $categoryProductRepository;
206
207
    /**
208
     * The repository to load the stock item with.
209
     *
210
     * @var \TechDivision\Import\Product\Repositories\StockItemRepository
211
     */
212
    protected $stockItemRepository;
213
214
    /**
215
     * The assembler to load the product attributes with.
216
     *
217
     * @var \TechDivision\Import\Product\Assemblers\ProductAttributeAssemblerInterface
218
     */
219
    protected $productAttributeAssembler;
220
221
    /**
222
     * Initialize the processor with the necessary assembler and repository instances.
223
     *
224
     * @param \TechDivision\Import\Connection\ConnectionInterface                        $connection                        The connection to use
225
     * @param \TechDivision\Import\Product\Repositories\ProductRepository                $productRepository                 The product repository to use
226
     * @param \TechDivision\Import\Product\Repositories\ProductWebsiteRepository         $productWebsiteRepository          The product website repository to use
227
     * @param \TechDivision\Import\Product\Repositories\ProductDatetimeRepository        $productDatetimeRepository         The product datetime repository to use
228
     * @param \TechDivision\Import\Product\Repositories\ProductDecimalRepository         $productDecimalRepository          The product decimal repository to use
229
     * @param \TechDivision\Import\Product\Repositories\ProductIntRepository             $productIntRepository              The product integer repository to use
230
     * @param \TechDivision\Import\Product\Repositories\ProductTextRepository            $productTextRepository             The product text repository to use
231
     * @param \TechDivision\Import\Product\Repositories\ProductVarcharRepository         $productVarcharRepository          The product varchar repository to use
232
     * @param \TechDivision\Import\Product\Repositories\CategoryProductRepository        $categoryProductRepository         The category product repository to use
233
     * @param \TechDivision\Import\Product\Repositories\StockItemRepository              $stockItemRepository               The stock item repository to use
234
     * @param \TechDivision\Import\Repositories\EavAttributeOptionValueRepository        $eavAttributeOptionValueRepository The EAV attribute option value repository to use
235
     * @param \TechDivision\Import\Repositories\EavAttributeRepository                   $eavAttributeRepository            The EAV attribute repository to use
236
     * @param \TechDivision\Import\Product\Actions\CategoryProductActionInterface        $categoryProductAction             The category product action to use
237
     * @param \TechDivision\Import\Product\Actions\ProductDatetimeActionInterface        $productDatetimeAction             The product datetime action to use
238
     * @param \TechDivision\Import\Product\Actions\ProductDecimalActionInterface         $productDecimalAction              The product decimal action to use
239
     * @param \TechDivision\Import\Product\Actions\ProductIntActionInterface             $productIntAction                  The product integer action to use
240
     * @param \TechDivision\Import\Product\Actions\ProductAction                         $productAction                     The product action to use
241
     * @param \TechDivision\Import\Product\Actions\ProductTextActionInterface            $productTextAction                 The product text action to use
242
     * @param \TechDivision\Import\Product\Actions\ProductVarcharActionInterface         $productVarcharAction              The product varchar action to use
243
     * @param \TechDivision\Import\Product\Actions\ProductWebsiteActionInterface         $productWebsiteAction              The product website action to use
244
     * @param \TechDivision\Import\Product\Actions\StockItemActionInterface              $stockItemAction                   The stock item action to use
245
     * @param \TechDivision\Import\Actions\UrlRewriteAction                              $urlRewriteAction                  The URL rewrite action to use
246
     * @param \TechDivision\Import\Product\Assemblers\ProductAttributeAssemblerInterface $productAttributeAssembler         The assembler to load the product attributes with
247
     */
248
    public function __construct(
249
        ConnectionInterface $connection,
250
        ProductRepository $productRepository,
251
        ProductWebsiteRepository $productWebsiteRepository,
252
        ProductDatetimeRepository $productDatetimeRepository,
253
        ProductDecimalRepository $productDecimalRepository,
254
        ProductIntRepository $productIntRepository,
255
        ProductTextRepository $productTextRepository,
256
        ProductVarcharRepository $productVarcharRepository,
257
        CategoryProductRepository $categoryProductRepository,
258
        StockItemRepository $stockItemRepository,
259
        EavAttributeOptionValueRepository $eavAttributeOptionValueRepository,
260
        EavAttributeRepository $eavAttributeRepository,
261
        CategoryProductActionInterface $categoryProductAction,
262
        ProductDatetimeActionInterface $productDatetimeAction,
263
        ProductDecimalActionInterface $productDecimalAction,
264
        ProductIntActionInterface $productIntAction,
265
        ProductAction $productAction,
266
        ProductTextActionInterface $productTextAction,
267
        ProductVarcharActionInterface $productVarcharAction,
268
        ProductWebsiteActionInterface $productWebsiteAction,
269
        StockItemActionInterface $stockItemAction,
270
        UrlRewriteAction $urlRewriteAction,
271
        ProductAttributeAssemblerInterface $productAttributeAssembler
272
    ) {
273
        $this->setConnection($connection);
274
        $this->setProductRepository($productRepository);
275
        $this->setProductWebsiteRepository($productWebsiteRepository);
276
        $this->setProductDatetimeRepository($productDatetimeRepository);
277
        $this->setProductDecimalRepository($productDecimalRepository);
278
        $this->setProductIntRepository($productIntRepository);
279
        $this->setProductTextRepository($productTextRepository);
280
        $this->setProductVarcharRepository($productVarcharRepository);
281
        $this->setCategoryProductRepository($categoryProductRepository);
282
        $this->setStockItemRepository($stockItemRepository);
283
        $this->setEavAttributeOptionValueRepository($eavAttributeOptionValueRepository);
284
        $this->setEavAttributeRepository($eavAttributeRepository);
285
        $this->setCategoryProductAction($categoryProductAction);
286
        $this->setProductDatetimeAction($productDatetimeAction);
287
        $this->setProductDecimalAction($productDecimalAction);
288
        $this->setProductIntAction($productIntAction);
289
        $this->setProductAction($productAction);
290
        $this->setProductTextAction($productTextAction);
291
        $this->setProductVarcharAction($productVarcharAction);
292
        $this->setProductWebsiteAction($productWebsiteAction);
293
        $this->setStockItemAction($stockItemAction);
294
        $this->setUrlRewriteAction($urlRewriteAction);
295
        $this->setProductAttributeAssembler($productAttributeAssembler);
296
    }
297
298
    /**
299
     * Set's the passed connection.
300
     *
301
     * @param \TechDivision\Import\Connection\ConnectionInterface $connection The connection to set
302
     *
303
     * @return void
304
     */
305
    public function setConnection(ConnectionInterface $connection)
306
    {
307
        $this->connection = $connection;
308
    }
309
310
    /**
311
     * Return's the connection.
312
     *
313
     * @return \TechDivision\Import\Connection\ConnectionInterface The connection instance
314
     */
315
    public function getConnection()
316
    {
317
        return $this->connection;
318
    }
319
320
    /**
321
     * Turns off autocommit mode. While autocommit mode is turned off, changes made to the database via the PDO
322
     * object instance are not committed until you end the transaction by calling ProductProcessor::commit().
323
     * Calling ProductProcessor::rollBack() will roll back all changes to the database and return the connection
324
     * to autocommit mode.
325
     *
326
     * @return boolean Returns TRUE on success or FALSE on failure
327
     * @link http://php.net/manual/en/pdo.begintransaction.php
328
     */
329
    public function beginTransaction()
330
    {
331
        return $this->connection->beginTransaction();
332
    }
333
334
    /**
335
     * Commits a transaction, returning the database connection to autocommit mode until the next call to
336
     * ProductProcessor::beginTransaction() starts a new transaction.
337
     *
338
     * @return boolean Returns TRUE on success or FALSE on failure
339
     * @link http://php.net/manual/en/pdo.commit.php
340
     */
341
    public function commit()
342
    {
343
        return $this->connection->commit();
344
    }
345
346
    /**
347
     * Rolls back the current transaction, as initiated by ProductProcessor::beginTransaction().
348
     *
349
     * If the database was set to autocommit mode, this function will restore autocommit mode after it has
350
     * rolled back the transaction.
351
     *
352
     * Some databases, including MySQL, automatically issue an implicit COMMIT when a database definition
353
     * language (DDL) statement such as DROP TABLE or CREATE TABLE is issued within a transaction. The implicit
354
     * COMMIT will prevent you from rolling back any other changes within the transaction boundary.
355
     *
356
     * @return boolean Returns TRUE on success or FALSE on failure
357
     * @link http://php.net/manual/en/pdo.rollback.php
358
     */
359
    public function rollBack()
360
    {
361
        return $this->connection->rollBack();
362
    }
363
364
    /**
365
     * Set's the repository to access EAV attribute option values.
366
     *
367
     * @param \TechDivision\Import\Repositories\EavAttributeOptionValueRepository $eavAttributeOptionValueRepository The repository to access EAV attribute option values
368
     *
369
     * @return void
370
     */
371
    public function setEavAttributeOptionValueRepository($eavAttributeOptionValueRepository)
372
    {
373
        $this->eavAttributeOptionValueRepository = $eavAttributeOptionValueRepository;
374
    }
375
376
    /**
377
     * Return's the repository to access EAV attribute option values.
378
     *
379
     * @return \TechDivision\Import\Repositories\EavAttributeOptionValueRepository The repository instance
380
     */
381
    public function getEavAttributeOptionValueRepository()
382
    {
383
        return $this->eavAttributeOptionValueRepository;
384
    }
385
386
    /**
387
     * Set's the repository to access EAV attributes.
388
     *
389
     * @param \TechDivision\Import\Repositories\EavAttributeRepository $eavAttributeRepository The repository to access EAV attributes
390
     *
391
     * @return void
392
     */
393
    public function setEavAttributeRepository($eavAttributeRepository)
394
    {
395
        $this->eavAttributeRepository = $eavAttributeRepository;
396
    }
397
398
    /**
399
     * Return's the repository to access EAV attributes.
400
     *
401
     * @return \TechDivision\Import\Repositories\EavAttributeRepository The repository instance
402
     */
403
    public function getEavAttributeRepository()
404
    {
405
        return $this->eavAttributeRepository;
406
    }
407
408
    /**
409
     * Return's an array with the available EAV attributes for the passed is user defined flag.
410
     *
411
     * @param integer $isUserDefined The flag itself
412
     *
413
     * @return array The array with the EAV attributes matching the passed flag
414
     */
415
    public function getEavAttributeByIsUserDefined($isUserDefined = 1)
416
    {
417
        return $this->getEavAttributeRepository()->findAllByIsUserDefined($isUserDefined);
418
    }
419
420
    /**
421
     * Set's the action with the product CRUD methods.
422
     *
423
     * @param \TechDivision\Import\Product\Actions\ProductAction $productAction The action with the product CRUD methods
424
     *
425
     * @return void
426
     */
427
    public function setProductAction($productAction)
428
    {
429
        $this->productAction = $productAction;
430
    }
431
432
    /**
433
     * Return's the action with the product CRUD methods.
434
     *
435
     * @return \TechDivision\Import\Product\Actions\ProductAction The action instance
436
     */
437
    public function getProductAction()
438
    {
439
        return $this->productAction;
440
    }
441
442
    /**
443
     * Set's the action with the product varchar attribute CRUD methods.
444
     *
445
     * @param \TechDivision\Import\Product\Actions\ProductVarcharActionInterface $productVarcharAction The action with the product varchar attriute CRUD methods
446
     *
447
     * @return void
448
     */
449
    public function setProductVarcharAction($productVarcharAction)
450
    {
451
        $this->productVarcharAction = $productVarcharAction;
452
    }
453
454
    /**
455
     * Return's the action with the product varchar attribute CRUD methods.
456
     *
457
     * @return \TechDivision\Import\Product\Actions\ProductVarcharActionInterface The action instance
458
     */
459
    public function getProductVarcharAction()
460
    {
461
        return $this->productVarcharAction;
462
    }
463
464
    /**
465
     * Set's the action with the product text attribute CRUD methods.
466
     *
467
     * @param \TechDivision\Import\Product\Actions\ProductTextActionInterface $productTextAction The action with the product text attriute CRUD methods
468
     *
469
     * @return void
470
     */
471
    public function setProductTextAction($productTextAction)
472
    {
473
        $this->productTextAction = $productTextAction;
474
    }
475
476
    /**
477
     * Return's the action with the product text attribute CRUD methods.
478
     *
479
     * @return \TechDivision\Import\Product\Actions\ProductTextActionInterface The action instance
480
     */
481
    public function getProductTextAction()
482
    {
483
        return $this->productTextAction;
484
    }
485
486
    /**
487
     * Set's the action with the product int attribute CRUD methods.
488
     *
489
     * @param \TechDivision\Import\Product\Actions\ProductIntActionInterface $productIntAction The action with the product int attriute CRUD methods
490
     *
491
     * @return void
492
     */
493
    public function setProductIntAction($productIntAction)
494
    {
495
        $this->productIntAction = $productIntAction;
496
    }
497
498
    /**
499
     * Return's the action with the product int attribute CRUD methods.
500
     *
501
     * @return \TechDivision\Import\Product\Actions\ProductIntActionInterface The action instance
502
     */
503
    public function getProductIntAction()
504
    {
505
        return $this->productIntAction;
506
    }
507
508
    /**
509
     * Set's the action with the product decimal attribute CRUD methods.
510
     *
511
     * @param \TechDivision\Import\Product\Actions\ProductDecimalActionInterface $productDecimalAction The action with the product decimal attriute CRUD methods
512
     *
513
     * @return void
514
     */
515
    public function setProductDecimalAction($productDecimalAction)
516
    {
517
        $this->productDecimalAction = $productDecimalAction;
518
    }
519
520
    /**
521
     * Return's the action with the product decimal attribute CRUD methods.
522
     *
523
     * @return \TechDivision\Import\Product\Actions\ProductDecimalActionInterface The action instance
524
     */
525
    public function getProductDecimalAction()
526
    {
527
        return $this->productDecimalAction;
528
    }
529
530
    /**
531
     * Set's the action with the product datetime attribute CRUD methods.
532
     *
533
     * @param \TechDivision\Import\Product\Actions\ProductDatetimeActionInterface $productDatetimeAction The action with the product datetime attriute CRUD methods
534
     *
535
     * @return void
536
     */
537
    public function setProductDatetimeAction($productDatetimeAction)
538
    {
539
        $this->productDatetimeAction = $productDatetimeAction;
540
    }
541
542
    /**
543
     * Return's the action with the product datetime attribute CRUD methods.
544
     *
545
     * @return \TechDivision\Import\Product\Actions\ProductDatetimeActionInterface The action instance
546
     */
547
    public function getProductDatetimeAction()
548
    {
549
        return $this->productDatetimeAction;
550
    }
551
552
    /**
553
     * Set's the action with the product website CRUD methods.
554
     *
555
     * @param \TechDivision\Import\Product\Actions\ProductWebsiteActionInterface $productWebsiteAction The action with the product website CRUD methods
556
     *
557
     * @return void
558
     */
559
    public function setProductWebsiteAction($productWebsiteAction)
560
    {
561
        $this->productWebsiteAction = $productWebsiteAction;
562
    }
563
564
    /**
565
     * Return's the action with the product website CRUD methods.
566
     *
567
     * @return \TechDivision\Import\Product\Actions\ProductWebsiteActionInterface The action instance
568
     */
569
    public function getProductWebsiteAction()
570
    {
571
        return $this->productWebsiteAction;
572
    }
573
574
    /**
575
     * Set's the action with the category product relation CRUD methods.
576
     *
577
     * @param \TechDivision\Import\Product\Actions\CategoryProductActionInterface $categoryProductAction The action with the category product relation CRUD methods
578
     *
579
     * @return void
580
     */
581
    public function setCategoryProductAction($categoryProductAction)
582
    {
583
        $this->categoryProductAction = $categoryProductAction;
584
    }
585
586
    /**
587
     * Return's the action with the category product relation CRUD methods.
588
     *
589
     * @return \TechDivision\Import\Product\Actions\CategoryProductActionInterface The action instance
590
     */
591
    public function getCategoryProductAction()
592
    {
593
        return $this->categoryProductAction;
594
    }
595
596
    /**
597
     * Set's the action with the stock item CRUD methods.
598
     *
599
     * @param \TechDivision\Import\Product\Actions\StockItemActionInterface $stockItemAction The action with the stock item CRUD methods
600
     *
601
     * @return void
602
     */
603
    public function setStockItemAction($stockItemAction)
604
    {
605
        $this->stockItemAction = $stockItemAction;
606
    }
607
608
    /**
609
     * Return's the action with the stock item CRUD methods.
610
     *
611
     * @return \TechDivision\Import\Product\Actions\StockItemActionInterface The action instance
612
     */
613
    public function getStockItemAction()
614
    {
615
        return $this->stockItemAction;
616
    }
617
618
    /**
619
     * Set's the action with the URL rewrite CRUD methods.
620
     *
621
     * @param \TechDivision\Import\Actions\UrlRewriteAction $urlRewriteAction The action with the URL rewrite CRUD methods
622
     *
623
     * @return void
624
     */
625
    public function setUrlRewriteAction($urlRewriteAction)
626
    {
627
        $this->urlRewriteAction = $urlRewriteAction;
628
    }
629
630
    /**
631
     * Return's the action with the URL rewrite CRUD methods.
632
     *
633
     * @return \TechDivision\Import\Actions\UrlRewriteAction The action instance
634
     */
635
    public function getUrlRewriteAction()
636
    {
637
        return $this->urlRewriteAction;
638
    }
639
640
    /**
641
     * Set's the repository to load the products with.
642
     *
643
     * @param \TechDivision\Import\Product\Repositories\ProductRepository $productRepository The repository instance
644
     *
645
     * @return void
646
     */
647
    public function setProductRepository($productRepository)
648
    {
649
        $this->productRepository = $productRepository;
650
    }
651
652
    /**
653
     * Return's the repository to load the products with.
654
     *
655
     * @return \TechDivision\Import\Product\Repositories\ProductRepository The repository instance
656
     */
657
    public function getProductRepository()
658
    {
659
        return $this->productRepository;
660
    }
661
662
    /**
663
     * Set's the repository to load the product website relations with.
664
     *
665
     * @param \TechDivision\Import\Product\Repositories\ProductWebsiteRepository $productWebsiteRepository The repository instance
666
     *
667
     * @return void
668
     */
669
    public function setProductWebsiteRepository($productWebsiteRepository)
670
    {
671
        $this->productWebsiteRepository = $productWebsiteRepository;
672
    }
673
674
    /**
675
     * Return's the repository to load the product website relations with.
676
     *
677
     * @return \TechDivision\Import\Product\Repositories\ProductWebsiteRepository The repository instance
678
     */
679
    public function getProductWebsiteRepository()
680
    {
681
        return $this->productWebsiteRepository;
682
    }
683
684
    /**
685
     * Set's the repository to load the product datetime attribute with.
686
     *
687
     * @param \TechDivision\Import\Product\Repositories\ProductDatetimeRepository $productDatetimeRepository The repository instance
688
     *
689
     * @return void
690
     */
691
    public function setProductDatetimeRepository($productDatetimeRepository)
692
    {
693
        $this->productDatetimeRepository = $productDatetimeRepository;
694
    }
695
696
    /**
697
     * Return's the repository to load the product datetime attribute with.
698
     *
699
     * @return \TechDivision\Import\Product\Repositories\ProductDatetimeRepository The repository instance
700
     */
701
    public function getProductDatetimeRepository()
702
    {
703
        return $this->productDatetimeRepository;
704
    }
705
706
    /**
707
     * Set's the repository to load the product decimal attribute with.
708
     *
709
     * @param \TechDivision\Import\Product\Repositories\ProductDecimalRepository $productDecimalRepository The repository instance
710
     *
711
     * @return void
712
     */
713
    public function setProductDecimalRepository($productDecimalRepository)
714
    {
715
        $this->productDecimalRepository = $productDecimalRepository;
716
    }
717
718
    /**
719
     * Return's the repository to load the product decimal attribute with.
720
     *
721
     * @return \TechDivision\Import\Product\Repositories\ProductDecimalRepository The repository instance
722
     */
723
    public function getProductDecimalRepository()
724
    {
725
        return $this->productDecimalRepository;
726
    }
727
728
    /**
729
     * Set's the repository to load the product integer attribute with.
730
     *
731
     * @param \TechDivision\Import\Product\Repositories\ProductIntRepository $productIntRepository The repository instance
732
     *
733
     * @return void
734
     */
735
    public function setProductIntRepository($productIntRepository)
736
    {
737
        $this->productIntRepository = $productIntRepository;
738
    }
739
740
    /**
741
     * Return's the repository to load the product integer attribute with.
742
     *
743
     * @return \TechDivision\Import\Product\Repositories\ProductIntRepository The repository instance
744
     */
745
    public function getProductIntRepository()
746
    {
747
        return $this->productIntRepository;
748
    }
749
750
    /**
751
     * Set's the repository to load the product text attribute with.
752
     *
753
     * @param \TechDivision\Import\Product\Repositories\ProductTextRepository $productTextRepository The repository instance
754
     *
755
     * @return void
756
     */
757
    public function setProductTextRepository($productTextRepository)
758
    {
759
        $this->productTextRepository = $productTextRepository;
760
    }
761
762
    /**
763
     * Return's the repository to load the product text attribute with.
764
     *
765
     * @return \TechDivision\Import\Product\Repositories\ProductTextRepository The repository instance
766
     */
767
    public function getProductTextRepository()
768
    {
769
        return $this->productTextRepository;
770
    }
771
772
    /**
773
     * Set's the repository to load the product varchar attribute with.
774
     *
775
     * @param \TechDivision\Import\Product\Repositories\ProductVarcharRepository $productVarcharRepository The repository instance
776
     *
777
     * @return void
778
     */
779
    public function setProductVarcharRepository($productVarcharRepository)
780
    {
781
        $this->productVarcharRepository = $productVarcharRepository;
782
    }
783
784
    /**
785
     * Return's the repository to load the product varchar attribute with.
786
     *
787
     * @return \TechDivision\Import\Product\Repositories\ProductVarcharRepository The repository instance
788
     */
789
    public function getProductVarcharRepository()
790
    {
791
        return $this->productVarcharRepository;
792
    }
793
794
    /**
795
     * Set's the repository to load the category product relations with.
796
     *
797
     * @param \TechDivision\Import\Product\Repositories\CategoryProductRepository $categoryProductRepository The repository instance
798
     *
799
     * @return void
800
     */
801
    public function setCategoryProductRepository($categoryProductRepository)
802
    {
803
        $this->categoryProductRepository = $categoryProductRepository;
804
    }
805
806
    /**
807
     * Return's the repository to load the category product relations with.
808
     *
809
     * @return \TechDivision\Import\Product\Repositories\CategoryProductRepository The repository instance
810
     */
811
    public function getCategoryProductRepository()
812
    {
813
        return $this->categoryProductRepository;
814
    }
815
816
    /**
817
     * Set's the repository to load the stock items with.
818
     *
819
     * @param \TechDivision\Import\Product\Repositories\StockItemRepository $stockItemRepository The repository instance
820
     *
821
     * @return void
822
     */
823
    public function setStockItemRepository($stockItemRepository)
824
    {
825
        $this->stockItemRepository = $stockItemRepository;
826
    }
827
828
    /**
829
     * Return's the repository to load the stock items with.
830
     *
831
     * @return \TechDivision\Import\Product\Repositories\StockItemRepository The repository instance
832
     */
833
    public function getStockItemRepository()
834
    {
835
        return $this->stockItemRepository;
836
    }
837
838
    /**
839
     * Set's the assembler to load the product attributes with.
840
     *
841
     * @param \TechDivision\Import\Product\Assemblers\ProductAttributeAssemblerInterface $productAttributeAssembler The assembler instance
842
     *
843
     * @return void
844
     */
845
    public function setProductAttributeAssembler(ProductAttributeAssemblerInterface $productAttributeAssembler)
846
    {
847
        $this->productAttributeAssembler = $productAttributeAssembler;
848
    }
849
850
    /**
851
     * Return's the assembler to load the product attributes with.
852
     *
853
     * @return \TechDivision\Import\Product\Assemblers\ProductAttributeAssemblerInterface The assembler instance
854
     */
855
    public function getProductAttributeAssembler()
856
    {
857
        return $this->productAttributeAssembler;
858
    }
859
860
    /**
861
     * Return's the category product relations for the product with the passed SKU.
862
     *
863
     * @param string $sku The product SKU to load the category relations for
864
     *
865
     * @return array The category product relations for the product with the passed SKU
866
     */
867
    public function getCategoryProductsBySku($sku)
868
    {
869
        return $this->getCategoryProductRepository()->findAllBySku($sku);
870
    }
871
872
    /**
873
     * Intializes the existing attributes for the entity with the passed primary key.
874
     *
875
     * @param string  $pk      The primary key of the entity to load the attributes for
876
     * @param integer $storeId The ID of the store view to load the attributes for
877
     *
878
     * @return array The entity attributes
879
     */
880
    public function getProductAttributesByPrimaryKeyAndStoreId($pk, $storeId)
881
    {
882
        return $this->getProductAttributeAssembler()->getProductAttributesByPrimaryKeyAndStoreId($pk, $storeId);
883
    }
884
885
    /**
886
     * Load's and return's the EAV attribute option value with the passed code, store ID and value.
887
     *
888
     * @param string  $attributeCode The code of the EAV attribute option to load
889
     * @param integer $storeId       The store ID of the attribute option to load
890
     * @param string  $value         The value of the attribute option to load
891
     *
892
     * @return array The EAV attribute option value
893
     */
894
    public function loadEavAttributeOptionValueByAttributeCodeAndStoreIdAndValue($attributeCode, $storeId, $value)
895
    {
896
        return $this->getEavAttributeOptionValueRepository()->findOneByAttributeCodeAndStoreIdAndValue($attributeCode, $storeId, $value);
897
    }
898
899
    /**
900
     * Load's and return's the product with the passed SKU.
901
     *
902
     * @param string $sku The SKU of the product to load
903
     *
904
     * @return array The product
905
     */
906
    public function loadProduct($sku)
907
    {
908
        return $this->getProductRepository()->findOneBySku($sku);
909
    }
910
911
    /**
912
     * Load's and return's the product website relation with the passed product and website ID.
913
     *
914
     * @param string $productId The product ID of the relation
915
     * @param string $websiteId The website ID of the relation
916
     *
917
     * @return array The product website
918
     */
919
    public function loadProductWebsite($productId, $websiteId)
920
    {
921
        return $this->getProductWebsiteRepository()->findOneByProductIdAndWebsite($productId, $websiteId);
922
    }
923
924
    /**
925
     * Return's the category product relation with the passed category/product ID.
926
     *
927
     * @param integer $categoryId The category ID of the category product relation to return
928
     * @param integer $productId  The product ID of the category product relation to return
929
     *
930
     * @return array The category product relation
931
     */
932
    public function loadCategoryProduct($categoryId, $productId)
933
    {
934
        return $this->getCategoryProductRepository()->findOneByCategoryIdAndProductId($categoryId, $productId);
935
    }
936
937
    /**
938
     * Load's and return's the stock status with the passed product/website/stock ID.
939
     *
940
     * @param integer $productId The product ID of the stock item to load
941
     * @param integer $websiteId The website ID of the stock item to load
942
     * @param integer $stockId   The stock ID of the stock item to load
943
     *
944
     * @return array The stock item
945
     */
946
    public function loadStockItem($productId, $websiteId, $stockId)
947
    {
948
        return $this->getStockItemRepository()->findOneByProductIdAndWebsiteIdAndStockId($productId, $websiteId, $stockId);
949
    }
950
951
    /**
952
     * Load's and return's the varchar attribute with the passed params.
953
     *
954
     * @param integer $attributeCode The attribute code of the varchar attribute
955
     * @param integer $entityTypeId  The entity type ID of the varchar attribute
956
     * @param integer $storeId       The store ID of the varchar attribute
957
     * @param string  $value         The value of the varchar attribute
958
     *
959
     * @return array|null The varchar attribute
960
     */
961
    public function loadProductVarcharAttributeByAttributeCodeAndEntityTypeIdAndStoreIdAndValue($attributeCode, $entityTypeId, $storeId, $value)
962
    {
963
        return $this->getProductVarcharRepository()->findOneByAttributeCodeAndEntityTypeIdAndStoreIdAndValue($attributeCode, $entityTypeId, $storeId, $value);
964
    }
965
966
    /**
967
     * Persist's the passed product data and return's the ID.
968
     *
969
     * @param array       $product The product data to persist
970
     * @param string|null $name    The name of the prepared statement that has to be executed
971
     *
972
     * @return string The ID of the persisted entity
973
     */
974
    public function persistProduct($product, $name = null)
975
    {
976
977
        // persist the new entity and return the ID
978
        $id = $this->getProductAction()->persist($product, $name);
0 ignored issues
show
Unused Code introduced by
The call to ProductAction::persist() has too many arguments starting with $name.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
979
980
        // add the product to the cache, register the SKU reference as well
981
        $this->getProductRepository()->toCache($product[MemberNames::SKU], $product, array($product[MemberNames::SKU] => $id));
982
983
        // return the ID of the persisted product
984
        return $id;
985
    }
986
987
    /**
988
     * Persist's the passed product varchar attribute.
989
     *
990
     * @param array       $attribute The attribute to persist
991
     * @param string|null $name      The name of the prepared statement that has to be executed
992
     *
993
     * @return void
994
     */
995
    public function persistProductVarcharAttribute($attribute, $name = null)
996
    {
997
        $this->getProductVarcharAction()->persist($attribute, $name);
0 ignored issues
show
Unused Code introduced by
The call to ProductVarcharActionInterface::persist() has too many arguments starting with $name.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
998
    }
999
1000
    /**
1001
     * Persist's the passed product integer attribute.
1002
     *
1003
     * @param array       $attribute The attribute to persist
1004
     * @param string|null $name      The name of the prepared statement that has to be executed
1005
     *
1006
     * @return void
1007
     */
1008
    public function persistProductIntAttribute($attribute, $name = null)
1009
    {
1010
        $this->getProductIntAction()->persist($attribute, $name);
0 ignored issues
show
Unused Code introduced by
The call to ProductIntActionInterface::persist() has too many arguments starting with $name.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
1011
    }
1012
1013
    /**
1014
     * Persist's the passed product decimal attribute.
1015
     *
1016
     * @param array       $attribute The attribute to persist
1017
     * @param string|null $name      The name of the prepared statement that has to be executed
1018
     *
1019
     * @return void
1020
     */
1021
    public function persistProductDecimalAttribute($attribute, $name = null)
1022
    {
1023
        $this->getProductDecimalAction()->persist($attribute, $name);
0 ignored issues
show
Unused Code introduced by
The call to ProductDecimalActionInterface::persist() has too many arguments starting with $name.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
1024
    }
1025
1026
    /**
1027
     * Persist's the passed product datetime attribute.
1028
     *
1029
     * @param array       $attribute The attribute to persist
1030
     * @param string|null $name      The name of the prepared statement that has to be executed
1031
     *
1032
     * @return void
1033
     */
1034
    public function persistProductDatetimeAttribute($attribute, $name = null)
1035
    {
1036
        $this->getProductDatetimeAction()->persist($attribute, $name);
0 ignored issues
show
Unused Code introduced by
The call to ProductDatetimeActionInterface::persist() has too many arguments starting with $name.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
1037
    }
1038
1039
    /**
1040
     * Persist's the passed product text attribute.
1041
     *
1042
     * @param array       $attribute The attribute to persist
1043
     * @param string|null $name      The name of the prepared statement that has to be executed
1044
     *
1045
     * @return void
1046
     */
1047
    public function persistProductTextAttribute($attribute, $name = null)
1048
    {
1049
        $this->getProductTextAction()->persist($attribute, $name);
0 ignored issues
show
Unused Code introduced by
The call to ProductTextActionInterface::persist() has too many arguments starting with $name.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
1050
    }
1051
1052
    /**
1053
     * Persist's the passed product website data and return's the ID.
1054
     *
1055
     * @param array       $productWebsite The product website data to persist
1056
     * @param string|null $name           The name of the prepared statement that has to be executed
1057
     *
1058
     * @return void
1059
     */
1060
    public function persistProductWebsite($productWebsite, $name = null)
1061
    {
1062
        $this->getProductWebsiteAction()->persist($productWebsite, $name);
0 ignored issues
show
Unused Code introduced by
The call to ProductWebsiteActionInterface::persist() has too many arguments starting with $name.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
1063
    }
1064
1065
    /**
1066
     * Persist's the passed category product relation.
1067
     *
1068
     * @param array       $categoryProduct The category product relation to persist
1069
     * @param string|null $name            The name of the prepared statement that has to be executed
1070
     *
1071
     * @return void
1072
     */
1073
    public function persistCategoryProduct($categoryProduct, $name = null)
1074
    {
1075
        $this->getCategoryProductAction()->persist($categoryProduct, $name);
0 ignored issues
show
Unused Code introduced by
The call to CategoryProductActionInterface::persist() has too many arguments starting with $name.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
1076
    }
1077
1078
    /**
1079
     * Persist's the passed stock item data and return's the ID.
1080
     *
1081
     * @param array       $stockItem The stock item data to persist
1082
     * @param string|null $name      The name of the prepared statement that has to be executed
1083
     *
1084
     * @return void
1085
     */
1086
    public function persistStockItem($stockItem, $name = null)
1087
    {
1088
        $this->getStockItemAction()->persist($stockItem, $name);
0 ignored issues
show
Unused Code introduced by
The call to StockItemActionInterface::persist() has too many arguments starting with $name.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
1089
    }
1090
1091
    /**
1092
     * Delete's the entity with the passed attributes.
1093
     *
1094
     * @param array       $row  The attributes of the entity to delete
1095
     * @param string|null $name The name of the prepared statement that has to be executed
1096
     *
1097
     * @return void
1098
     */
1099
    public function deleteProduct($row, $name = null)
1100
    {
1101
        $this->getProductAction()->delete($row, $name);
1102
    }
1103
1104
    /**
1105
     * Delete's the URL rewrite with the passed attributes.
1106
     *
1107
     * @param array       $row  The attributes of the entity to delete
1108
     * @param string|null $name The name of the prepared statement that has to be executed
1109
     *
1110
     * @return void
1111
     */
1112
    public function deleteUrlRewrite($row, $name = null)
1113
    {
1114
        $this->getUrlRewriteAction()->delete($row, $name);
1115
    }
1116
1117
    /**
1118
     * Delete's the stock item(s) with the passed attributes.
1119
     *
1120
     * @param array       $row  The attributes of the entity to delete
1121
     * @param string|null $name The name of the prepared statement that has to be executed
1122
     *
1123
     * @return void
1124
     */
1125
    public function deleteStockItem($row, $name = null)
1126
    {
1127
        $this->getStockItemAction()->delete($row, $name);
1128
    }
1129
1130
    /**
1131
     * Delete's the product website relations with the passed attributes.
1132
     *
1133
     * @param array       $row  The attributes of the entity to delete
1134
     * @param string|null $name The name of the prepared statement that has to be executed
1135
     *
1136
     * @return void
1137
     */
1138
    public function deleteProductWebsite($row, $name = null)
1139
    {
1140
        $this->getProductWebsiteAction()->delete($row, $name);
1141
    }
1142
1143
    /**
1144
     * Delete's the category product relations with the passed attributes.
1145
     *
1146
     * @param array       $row  The attributes of the entity to delete
1147
     * @param string|null $name The name of the prepared statement that has to be executed
1148
     *
1149
     * @return void
1150
     */
1151
    public function deleteCategoryProduct($row, $name = null)
1152
    {
1153
        $this->getCategoryProductAction()->delete($row, $name);
1154
    }
1155
1156
    /**
1157
     * Delete's the product datetime attribute with the passed attributes.
1158
     *
1159
     * @param array       $row  The attributes of the entity to delete
1160
     * @param string|null $name The name of the prepared statement that has to be executed
1161
     *
1162
     * @return void
1163
     */
1164
    public function deleteProductDatetimeAttribute($row, $name = null)
1165
    {
1166
        $this->getProductDatetimeAction()->delete($row, $name);
1167
    }
1168
1169
    /**
1170
     * Delete's the product decimal attribute with the passed attributes.
1171
     *
1172
     * @param array       $row  The attributes of the entity to delete
1173
     * @param string|null $name The name of the prepared statement that has to be executed
1174
     *
1175
     * @return void
1176
     */
1177
    public function deleteProductDecimalAttribute($row, $name = null)
1178
    {
1179
        $this->getProductDecimalAction()->delete($row, $name);
1180
    }
1181
1182
    /**
1183
     * Delete's the product integer attribute with the passed attributes.
1184
     *
1185
     * @param array       $row  The attributes of the entity to delete
1186
     * @param string|null $name The name of the prepared statement that has to be executed
1187
     *
1188
     * @return void
1189
     */
1190
    public function deleteProductIntAttribute($row, $name = null)
1191
    {
1192
        $this->getProductIntAction()->delete($row, $name);
1193
    }
1194
1195
    /**
1196
     * Delete's the product text attribute with the passed attributes.
1197
     *
1198
     * @param array       $row  The attributes of the entity to delete
1199
     * @param string|null $name The name of the prepared statement that has to be executed
1200
     *
1201
     * @return void
1202
     */
1203
    public function deleteProductTextAttribute($row, $name = null)
1204
    {
1205
        $this->getProductTextAction()->delete($row, $name);
1206
    }
1207
1208
    /**
1209
     * Delete's the product varchar attribute with the passed attributes.
1210
     *
1211
     * @param array       $row  The attributes of the entity to delete
1212
     * @param string|null $name The name of the prepared statement that has to be executed
1213
     *
1214
     * @return void
1215
     */
1216
    public function deleteProductVarcharAttribute($row, $name = null)
1217
    {
1218
        $this->getProductVarcharAction()->delete($row, $name);
1219
    }
1220
1221
    /**
1222
     * Clean-Up the repositories to free memory.
1223
     *
1224
     * @return void
1225
     */
1226
    public function cleanUp()
1227
    {
1228
        $this->getProductRepository()->flushCache();
1229
    }
1230
}
1231