1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* TechDivision\Import\Cli\Services\ProductVariantProcessorFactory |
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-cli-simple |
18
|
|
|
* @link http://www.techdivision.com |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace TechDivision\Import\Cli\Services; |
22
|
|
|
|
23
|
|
|
use TechDivision\Import\Configuration\SubjectInterface; |
24
|
|
|
use TechDivision\Import\Repositories\EavAttributeRepository; |
25
|
|
|
use TechDivision\Import\Repositories\EavAttributeOptionValueRepository; |
26
|
|
|
use TechDivision\Import\Product\Variant\Repositories\ProductRelationRepository; |
27
|
|
|
use TechDivision\Import\Product\Variant\Repositories\ProductSuperLinkRepository; |
28
|
|
|
use TechDivision\Import\Product\Variant\Repositories\ProductSuperAttributeRepository; |
29
|
|
|
use TechDivision\Import\Product\Variant\Repositories\ProductSuperAttributeLabelRepository; |
30
|
|
|
use TechDivision\Import\Product\Variant\Actions\ProductRelationAction; |
31
|
|
|
use TechDivision\Import\Product\Variant\Actions\ProductSuperAttributeAction; |
32
|
|
|
use TechDivision\Import\Product\Variant\Actions\ProductSuperAttributeLabelAction; |
33
|
|
|
use TechDivision\Import\Product\Variant\Actions\ProductSuperLinkAction; |
34
|
|
|
use TechDivision\Import\Product\Variant\Actions\Processors\ProductRelationCreateProcessor; |
35
|
|
|
use TechDivision\Import\Product\Variant\Actions\Processors\ProductSuperLinkCreateProcessor; |
36
|
|
|
use TechDivision\Import\Product\Variant\Actions\Processors\ProductSuperAttributeCreateProcessor; |
37
|
|
|
use TechDivision\Import\Product\Variant\Actions\Processors\ProductSuperAttributeUpdateProcessor; |
38
|
|
|
use TechDivision\Import\Product\Variant\Actions\Processors\ProductSuperAttributeLabelCreateProcessor; |
39
|
|
|
use TechDivision\Import\Product\Variant\Actions\Processors\ProductSuperAttributeLabelUpdateProcessor; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Factory to create a new product variant processor. |
43
|
|
|
* |
44
|
|
|
* @author Tim Wagner <[email protected]> |
45
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
46
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
47
|
|
|
* @link https://github.com/techdivision/import-cli-simple |
48
|
|
|
* @link http://www.techdivision.com |
49
|
|
|
*/ |
50
|
|
|
class ProductVariantProcessorFactory extends AbstractProductProcessorFactory |
51
|
|
|
{ |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Return's the processor class name. |
55
|
|
|
* |
56
|
|
|
* @return string The processor class name |
57
|
|
|
*/ |
58
|
|
|
protected static function getProcessorType() |
59
|
|
|
{ |
60
|
|
|
return 'TechDivision\Import\Product\Variant\Services\ProductVariantProcessor'; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Factory method to create a new product variant processor instance. |
65
|
|
|
* |
66
|
|
|
* @param \PDO $connection The PDO connection to use |
67
|
|
|
* @param TechDivision\Import\Configuration\SubjectInterface $configuration The subject configuration |
68
|
|
|
* |
69
|
|
|
* @return \TechDivision\Import\Product\Variant\Services\ProductVariantProcessor The processor instance |
70
|
|
|
*/ |
71
|
|
|
public static function factory(\PDO $connection, SubjectInterface $configuration) |
72
|
|
|
{ |
73
|
|
|
|
74
|
|
|
// load the utility class name |
75
|
|
|
$utilityClassName = $configuration->getUtilityClassName(); |
76
|
|
|
|
77
|
|
|
// initialize the repository that provides EAV attribute query functionality |
78
|
|
|
$eavAttributeRepository = new EavAttributeRepository(); |
79
|
|
|
$eavAttributeRepository->setUtilityClassName($utilityClassName); |
80
|
|
|
$eavAttributeRepository->setConnection($connection); |
81
|
|
|
$eavAttributeRepository->init(); |
82
|
|
|
|
83
|
|
|
// initialize the repository that provides EAV attribute option value query functionality |
84
|
|
|
$eavAttributeOptionValueRepository = new EavAttributeOptionValueRepository(); |
85
|
|
|
$eavAttributeOptionValueRepository->setUtilityClassName($utilityClassName); |
86
|
|
|
$eavAttributeOptionValueRepository->setConnection($connection); |
87
|
|
|
$eavAttributeOptionValueRepository->init(); |
88
|
|
|
|
89
|
|
|
// initialize the repository that provides product relation query functionality |
90
|
|
|
$productRelationRepository = new ProductRelationRepository(); |
91
|
|
|
$productRelationRepository->setUtilityClassName($utilityClassName); |
92
|
|
|
$productRelationRepository->setConnection($connection); |
93
|
|
|
$productRelationRepository->init(); |
94
|
|
|
|
95
|
|
|
// initialize the repository that provides product super link query functionality |
96
|
|
|
$productSuperLinkRepository = new ProductSuperLinkRepository(); |
97
|
|
|
$productSuperLinkRepository->setUtilityClassName($utilityClassName); |
98
|
|
|
$productSuperLinkRepository->setConnection($connection); |
99
|
|
|
$productSuperLinkRepository->init(); |
100
|
|
|
|
101
|
|
|
// initialize the repository that provides product super attribute query functionality |
102
|
|
|
$productSuperAttributeRepository = new ProductSuperAttributeRepository(); |
103
|
|
|
$productSuperAttributeRepository->setUtilityClassName($utilityClassName); |
104
|
|
|
$productSuperAttributeRepository->setConnection($connection); |
105
|
|
|
$productSuperAttributeRepository->init(); |
106
|
|
|
|
107
|
|
|
// initialize the repository that provides product super attribute label query functionality |
108
|
|
|
$productSuperAttributeLabelRepository = new ProductSuperAttributeLabelRepository(); |
109
|
|
|
$productSuperAttributeLabelRepository->setUtilityClassName($utilityClassName); |
110
|
|
|
$productSuperAttributeLabelRepository->setConnection($connection); |
111
|
|
|
$productSuperAttributeLabelRepository->init(); |
112
|
|
|
|
113
|
|
|
// initialize the action that provides product relation CRUD functionality |
114
|
|
|
$productRelationCreateProcessor = new ProductRelationCreateProcessor(); |
115
|
|
|
$productRelationCreateProcessor->setUtilityClassName($utilityClassName); |
116
|
|
|
$productRelationCreateProcessor->setConnection($connection); |
117
|
|
|
$productRelationCreateProcessor->init(); |
118
|
|
|
$productRelationAction = new ProductRelationAction(); |
119
|
|
|
$productRelationAction->setCreateProcessor($productRelationCreateProcessor); |
120
|
|
|
|
121
|
|
|
// initialize the action that provides product super attribute CRUD functionality |
122
|
|
|
$productSuperAttributeCreateProcessor = new ProductSuperAttributeCreateProcessor(); |
123
|
|
|
$productSuperAttributeCreateProcessor->setUtilityClassName($utilityClassName); |
124
|
|
|
$productSuperAttributeCreateProcessor->setConnection($connection); |
125
|
|
|
$productSuperAttributeCreateProcessor->init(); |
126
|
|
|
$productSuperAttributeUpdateProcessor = new ProductSuperAttributeUpdateProcessor(); |
127
|
|
|
$productSuperAttributeUpdateProcessor->setUtilityClassName($utilityClassName); |
128
|
|
|
$productSuperAttributeUpdateProcessor->setConnection($connection); |
129
|
|
|
$productSuperAttributeUpdateProcessor->init(); |
130
|
|
|
$productSuperAttributeAction = new ProductSuperAttributeAction(); |
131
|
|
|
$productSuperAttributeAction->setCreateProcessor($productSuperAttributeCreateProcessor); |
132
|
|
|
$productSuperAttributeAction->setUpdateProcessor($productSuperAttributeUpdateProcessor); |
133
|
|
|
|
134
|
|
|
// initialize the action that provides product super attribute label CRUD functionality |
135
|
|
|
$productSuperAttributeLabelCreateProcessor = new ProductSuperAttributeLabelCreateProcessor(); |
136
|
|
|
$productSuperAttributeLabelCreateProcessor->setUtilityClassName($utilityClassName); |
137
|
|
|
$productSuperAttributeLabelCreateProcessor->setConnection($connection); |
138
|
|
|
$productSuperAttributeLabelCreateProcessor->init(); |
139
|
|
|
$productSuperAttributeLabelUpdateProcessor = new ProductSuperAttributeLabelUpdateProcessor(); |
140
|
|
|
$productSuperAttributeLabelUpdateProcessor->setUtilityClassName($utilityClassName); |
141
|
|
|
$productSuperAttributeLabelUpdateProcessor->setConnection($connection); |
142
|
|
|
$productSuperAttributeLabelUpdateProcessor->init(); |
143
|
|
|
$productSuperAttributeLabelAction = new ProductSuperAttributeLabelAction(); |
144
|
|
|
$productSuperAttributeLabelAction->setCreateProcessor($productSuperAttributeLabelCreateProcessor); |
145
|
|
|
$productSuperAttributeLabelAction->setUpdateProcessor($productSuperAttributeLabelUpdateProcessor); |
146
|
|
|
|
147
|
|
|
// initialize the action that provides product super link CRUD functionality |
148
|
|
|
$productSuperLinkCreateProcessor = new ProductSuperLinkCreateProcessor(); |
149
|
|
|
$productSuperLinkCreateProcessor->setUtilityClassName($utilityClassName); |
150
|
|
|
$productSuperLinkCreateProcessor->setConnection($connection); |
151
|
|
|
$productSuperLinkCreateProcessor->init(); |
152
|
|
|
$productSuperLinkAction = new ProductSuperLinkAction(); |
153
|
|
|
$productSuperLinkAction->setCreateProcessor($productSuperLinkCreateProcessor); |
154
|
|
|
|
155
|
|
|
// initialize the product variant processor |
156
|
|
|
$processorType = ProductVariantProcessorFactory::getProcessorType(); |
157
|
|
|
$productVariantProcessor = new $processorType(); |
158
|
|
|
$productVariantProcessor->setConnection($connection); |
159
|
|
|
$productVariantProcessor->setEavAttributeOptionValueRepository($eavAttributeOptionValueRepository); |
160
|
|
|
$productVariantProcessor->setEavAttributeRepository($eavAttributeRepository); |
161
|
|
|
$productVariantProcessor->setProductRelationRepository($productRelationRepository); |
162
|
|
|
$productVariantProcessor->setProductSuperLinkRepository($productSuperLinkRepository); |
163
|
|
|
$productVariantProcessor->setProductSuperAttributeRepository($productSuperAttributeRepository); |
164
|
|
|
$productVariantProcessor->setProductSuperAttributeLabelRepository($productSuperAttributeLabelRepository); |
165
|
|
|
$productVariantProcessor->setProductRelationAction($productRelationAction); |
166
|
|
|
$productVariantProcessor->setProductSuperLinkAction($productSuperLinkAction); |
167
|
|
|
$productVariantProcessor->setProductSuperAttributeAction($productSuperAttributeAction); |
168
|
|
|
$productVariantProcessor->setProductSuperAttributeLabelAction($productSuperAttributeLabelAction); |
169
|
|
|
|
170
|
|
|
// return the instance |
171
|
|
|
return $productVariantProcessor; |
172
|
|
|
} |
173
|
|
|
} |
174
|
|
|
|