|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved. |
|
5
|
|
|
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace SprykerEco\Zed\AkeneoPimMiddlewareConnector\Business\Translator\Dictionary; |
|
9
|
|
|
|
|
10
|
|
|
use SprykerEco\Zed\AkeneoPimMiddlewareConnector\AkeneoPimMiddlewareConnectorConfig; |
|
11
|
|
|
use SprykerEco\Zed\AkeneoPimMiddlewareConnector\Business\Translator\TranslatorFunction\DefaultPriceSelector; |
|
12
|
|
|
use SprykerMiddleware\Zed\Process\Business\Translator\Dictionary\AbstractDictionary; |
|
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
class DefaultProductImportDictionary extends AbstractDictionary |
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* @var array |
|
18
|
|
|
*/ |
|
19
|
|
|
protected static $localeMap; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @var array |
|
23
|
|
|
*/ |
|
24
|
|
|
protected static $attributeMap; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var \SprykerEco\Zed\AkeneoPimMiddlewareConnector\AkeneoPimMiddlewareConnectorConfig |
|
28
|
|
|
*/ |
|
29
|
|
|
private $config; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @param \SprykerEco\Zed\AkeneoPimMiddlewareConnector\AkeneoPimMiddlewareConnectorConfig $config |
|
33
|
|
|
*/ |
|
34
|
|
|
public function __construct(AkeneoPimMiddlewareConnectorConfig $config) |
|
35
|
|
|
{ |
|
36
|
|
|
$this->config = $config; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @return array |
|
41
|
|
|
*/ |
|
42
|
|
|
public function getDictionary(): array |
|
43
|
|
|
{ |
|
44
|
|
|
return [ |
|
45
|
|
|
'values.*' => 'MeasureUnitToInt', |
|
46
|
|
|
'values.collection.data' => function ($value) { |
|
47
|
|
|
if (is_array($value)) { |
|
48
|
|
|
return reset($value); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
return $value; |
|
52
|
|
|
}, |
|
53
|
|
|
'parent' => [ |
|
54
|
|
|
'AddAbstractSkuIfNotExist', |
|
55
|
|
|
], |
|
56
|
|
|
'categories' => [ |
|
57
|
|
|
[ |
|
58
|
|
|
'ArrayToString', |
|
59
|
|
|
'options' => [ |
|
60
|
|
|
'glue' => ',', |
|
61
|
|
|
], |
|
62
|
|
|
], |
|
63
|
|
|
], |
|
64
|
|
|
'values' => [ |
|
65
|
|
|
[ |
|
66
|
|
|
'EnrichAttributes', |
|
67
|
|
|
'options' => [ |
|
68
|
|
|
'map' => $this->getAttributeMap(), |
|
69
|
|
|
'excludeKeys' => [ |
|
70
|
|
|
'country_availability', |
|
71
|
|
|
], |
|
72
|
|
|
], |
|
73
|
|
|
], |
|
74
|
|
|
[ |
|
75
|
|
|
'ValuesToAttributes', |
|
76
|
|
|
'options' => [ |
|
77
|
|
|
'locales' => $this->config->getLocalesForImport(), |
|
78
|
|
|
], |
|
79
|
|
|
], |
|
80
|
|
|
[ |
|
81
|
|
|
'DefaultValuesToLocalizedAttributes', |
|
82
|
|
|
'options' => [ |
|
83
|
|
|
'locales' => $this->config->getLocalesForImport(), |
|
84
|
|
|
], |
|
85
|
|
|
], |
|
86
|
|
|
], |
|
87
|
|
|
'values.localizedAttributes' => [ |
|
88
|
|
|
[ |
|
89
|
|
|
'AddMissingLocales', |
|
90
|
|
|
'options' => [ |
|
91
|
|
|
'locales' => $this->config->getLocalesForImport(), |
|
92
|
|
|
], |
|
93
|
|
|
], |
|
94
|
|
|
[ |
|
95
|
|
|
'LocaleKeysToIds', |
|
96
|
|
|
'options' => [ |
|
97
|
|
|
'map' => $this->getLocaleMap(), |
|
98
|
|
|
], |
|
99
|
|
|
], |
|
100
|
|
|
[ |
|
101
|
|
|
'MoveLocalizedAttributesToAttributes', |
|
102
|
|
|
'options' => [ |
|
103
|
|
|
'blacklist' => [ |
|
104
|
|
|
'name', |
|
105
|
|
|
'title', |
|
106
|
|
|
'product_description', |
|
107
|
|
|
'tax_set', |
|
108
|
|
|
'is_active_per_locale', |
|
109
|
|
|
'price', |
|
110
|
|
|
'bild_information', |
|
111
|
|
|
'picto_informationen', |
|
112
|
|
|
'meta_title', |
|
113
|
|
|
'meta_description', |
|
114
|
|
|
'meta_keywords', |
|
115
|
|
|
], |
|
116
|
|
|
], |
|
117
|
|
|
], |
|
118
|
|
|
], |
|
119
|
|
|
'values.price' => [ |
|
120
|
|
|
[ |
|
121
|
|
|
'DefaultPriceSelector', |
|
122
|
|
|
'options' => [ |
|
123
|
|
|
DefaultPriceSelector::OPTION_STORES => $this->config->getActiveStoresForProducts(), |
|
124
|
|
|
DefaultPriceSelector::OPTION_LOCALE_TO_PRICE_MAP => $this->config->getLocaleToPriceMap(), |
|
125
|
|
|
], |
|
126
|
|
|
], |
|
127
|
|
|
], |
|
128
|
|
|
'values.localizedAttributes.*' => [ |
|
129
|
|
|
[ |
|
130
|
|
|
'ExcludeKeysAssociativeFilter', |
|
131
|
|
|
'options' => [ |
|
132
|
|
|
'excludeKeys' => [ |
|
133
|
|
|
'price', |
|
134
|
|
|
'bild_information', |
|
135
|
|
|
'picto_information', |
|
136
|
|
|
'tax_set', |
|
137
|
|
|
], |
|
138
|
|
|
], |
|
139
|
|
|
], |
|
140
|
|
|
[ |
|
141
|
|
|
'AddMissingAttributes', |
|
142
|
|
|
'options' => [ |
|
143
|
|
|
'attributes' => [ |
|
144
|
|
|
'name' => '', |
|
145
|
|
|
'description' => '', |
|
146
|
|
|
'meta_title' => '', |
|
147
|
|
|
'meta_description' => '', |
|
148
|
|
|
'meta_keywords' => '', |
|
149
|
|
|
'is_searchable' => true, |
|
150
|
|
|
], |
|
151
|
|
|
], |
|
152
|
|
|
], |
|
153
|
|
|
[ |
|
154
|
|
|
'AddUrlToLocalizedAttributes', |
|
155
|
|
|
], |
|
156
|
|
|
], |
|
157
|
|
|
'values.attributes' => [ |
|
158
|
|
|
[ |
|
159
|
|
|
'ExcludeKeysAssociativeFilter', |
|
160
|
|
|
'options' => [ |
|
161
|
|
|
'excludeKeys' => [ |
|
162
|
|
|
'price', |
|
163
|
|
|
'country_availability', |
|
164
|
|
|
], |
|
165
|
|
|
], |
|
166
|
|
|
], |
|
167
|
|
|
[ |
|
168
|
|
|
'AddFamilyAttribute', |
|
169
|
|
|
], |
|
170
|
|
|
], |
|
171
|
|
|
]; |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
/** |
|
175
|
|
|
* @return array |
|
176
|
|
|
*/ |
|
177
|
|
|
protected function getLocaleMap(): array |
|
178
|
|
|
{ |
|
179
|
|
|
if (static::$localeMap === null) { |
|
|
|
|
|
|
180
|
|
|
$content = file_get_contents($this->config->getLocaleMapFilePath()); |
|
181
|
|
|
static::$localeMap = json_decode($content, true); |
|
182
|
|
|
} |
|
183
|
|
|
|
|
184
|
|
|
return static::$localeMap; |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
/** |
|
188
|
|
|
* @return array |
|
189
|
|
|
*/ |
|
190
|
|
|
protected function getAttributeMap(): array |
|
191
|
|
|
{ |
|
192
|
|
|
if (static::$attributeMap === null) { |
|
|
|
|
|
|
193
|
|
|
$content = file_get_contents($this->config->getAttributeMapFilePath()); |
|
194
|
|
|
static::$attributeMap = json_decode($content, true); |
|
195
|
|
|
} |
|
196
|
|
|
|
|
197
|
|
|
$formattedResult = []; |
|
198
|
|
|
|
|
199
|
|
|
foreach (static::$attributeMap as $key => $value) { |
|
200
|
|
|
$formattedResult[$value['attribute_key']] = $value; |
|
201
|
|
|
} |
|
202
|
|
|
|
|
203
|
|
|
return $formattedResult; |
|
204
|
|
|
} |
|
205
|
|
|
} |
|
206
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths