|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* TechDivision\Import\Utils\SqlStatements |
|
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 |
|
18
|
|
|
* @link http://www.techdivision.com |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace TechDivision\Import\Repositories; |
|
22
|
|
|
|
|
23
|
|
|
use TechDivision\Import\Utils\SqlStatementKeys; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Repository class with the SQL statements to use. |
|
27
|
|
|
* |
|
28
|
|
|
* @author Tim Wagner <[email protected]> |
|
29
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
|
30
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
31
|
|
|
* @link https://github.com/techdivision/import |
|
32
|
|
|
* @link http://www.techdivision.com |
|
33
|
|
|
*/ |
|
34
|
|
|
class SqlStatementRepository extends AbstractSqlStatementRepository |
|
35
|
|
|
{ |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* The SQL statements. |
|
39
|
|
|
* |
|
40
|
|
|
* @var array |
|
41
|
|
|
*/ |
|
42
|
|
|
private $statements = array( |
|
43
|
|
|
SqlStatementKeys::CATEGORIES => |
|
44
|
|
|
'SELECT t0.*, |
|
45
|
|
|
(SELECT `value` |
|
46
|
|
|
FROM ${table:eav_attribute} t1, ${table:catalog_category_entity_varchar} t2 |
|
47
|
|
|
WHERE t1.attribute_code = \'name\' |
|
48
|
|
|
AND t1.entity_type_id = 3 |
|
49
|
|
|
AND t2.attribute_id = t1.attribute_id |
|
50
|
|
|
AND t2.store_id = 0 |
|
51
|
|
|
AND t2.${pk:entity_id} = t0.${pk:entity_id}) AS name, |
|
52
|
|
|
(SELECT `value` |
|
53
|
|
|
FROM ${table:eav_attribute} t1, ${table:catalog_category_entity_varchar} t2 |
|
54
|
|
|
WHERE t1.attribute_code = \'url_key\' |
|
55
|
|
|
AND t1.entity_type_id = 3 |
|
56
|
|
|
AND t2.attribute_id = t1.attribute_id |
|
57
|
|
|
AND t2.store_id = 0 |
|
58
|
|
|
AND t2.${pk:entity_id} = t0.${pk:entity_id}) AS url_key, |
|
59
|
|
|
(SELECT `value` |
|
60
|
|
|
FROM ${table:eav_attribute} t1, ${table:catalog_category_entity_varchar} t2 |
|
61
|
|
|
WHERE t1.attribute_code = \'url_path\' |
|
62
|
|
|
AND t1.entity_type_id = 3 |
|
63
|
|
|
AND t2.attribute_id = t1.attribute_id |
|
64
|
|
|
AND t2.store_id = 0 |
|
65
|
|
|
AND t2.${pk:entity_id} = t0.${pk:entity_id}) AS url_path, |
|
66
|
|
|
(SELECT `value` |
|
67
|
|
|
FROM ${table:eav_attribute} t1, ${table:catalog_category_entity_varchar} t2 |
|
68
|
|
|
WHERE t1.attribute_code = \'is_anchor\' |
|
69
|
|
|
AND t1.entity_type_id = 3 |
|
70
|
|
|
AND t2.attribute_id = t1.attribute_id |
|
71
|
|
|
AND t2.store_id = 0 |
|
72
|
|
|
AND t2.${pk:entity_id} = t0.${pk:entity_id}) AS is_anchor |
|
73
|
|
|
FROM ${table:catalog_category_entity} AS t0', |
|
74
|
|
|
SqlStatementKeys::ROOT_CATEGORIES => |
|
75
|
|
|
'SELECT t2.code, t0.* |
|
76
|
|
|
FROM ${table:catalog_category_entity} t0 |
|
77
|
|
|
INNER JOIN ${table:store_group} t1 |
|
78
|
|
|
ON t1.root_category_id = t0.entity_id |
|
79
|
|
|
INNER JOIN ${table:store} t2 |
|
80
|
|
|
ON t2.group_id = t1.group_id', |
|
81
|
|
|
SqlStatementKeys::CATEGORIES_BY_STORE_VIEW => |
|
82
|
|
|
'SELECT t0.*, |
|
83
|
|
|
IF (name_store.value_id > 0, name_store.value, name_default.value) AS name, |
|
84
|
|
|
IF (url_key_store.value_id > 0, url_key_store.value, url_key_default.value) AS url_key, |
|
85
|
|
|
IF (url_path_store.value_id > 0, url_path_store.value, url_path_default.value) AS url_path, |
|
86
|
|
|
IF (is_anchor_store.value_id > 0, is_anchor_store.value, is_anchor_default.value) AS is_anchor |
|
87
|
|
|
FROM ${table:catalog_category_entity} AS t0 |
|
88
|
|
|
LEFT JOIN ${table:catalog_category_entity_varchar} AS name_store |
|
89
|
|
|
ON name_store.attribute_id = ( |
|
90
|
|
|
SELECT attribute_id FROM ${table:eav_attribute} |
|
91
|
|
|
WHERE attribute_code = \'name\' AND entity_type_id = 3 |
|
92
|
|
|
) |
|
93
|
|
|
AND name_store.store_id = :store_id |
|
94
|
|
|
AND name_store.entity_id = t0.entity_id |
|
95
|
|
|
LEFT JOIN ${table:catalog_category_entity_varchar} AS name_default |
|
96
|
|
|
ON name_default.attribute_id = ( |
|
97
|
|
|
SELECT attribute_id FROM ${table:eav_attribute} |
|
98
|
|
|
WHERE attribute_code = \'name\' AND entity_type_id = 3 |
|
99
|
|
|
) |
|
100
|
|
|
AND name_default.store_id = 0 |
|
101
|
|
|
AND name_default.entity_id = t0.entity_id |
|
102
|
|
|
LEFT JOIN ${table:catalog_category_entity_varchar} AS url_key_store |
|
103
|
|
|
ON url_key_store.attribute_id = ( |
|
104
|
|
|
SELECT attribute_id FROM ${table:eav_attribute} |
|
105
|
|
|
WHERE attribute_code = \'url_key\' AND entity_type_id = 3 |
|
106
|
|
|
) |
|
107
|
|
|
AND url_key_store.store_id = :store_id |
|
108
|
|
|
AND url_key_store.entity_id = t0.entity_id |
|
109
|
|
|
LEFT JOIN ${table:catalog_category_entity_varchar} AS url_key_default |
|
110
|
|
|
ON url_key_default.attribute_id = ( |
|
111
|
|
|
SELECT attribute_id FROM ${table:eav_attribute} |
|
112
|
|
|
WHERE attribute_code = \'url_key\' AND entity_type_id = 3 |
|
113
|
|
|
) |
|
114
|
|
|
AND url_key_default.store_id = 0 |
|
115
|
|
|
AND url_key_default.entity_id = t0.entity_id |
|
116
|
|
|
LEFT JOIN ${table:catalog_category_entity_varchar} AS url_path_store |
|
117
|
|
|
ON url_path_store.attribute_id = ( |
|
118
|
|
|
SELECT attribute_id FROM ${table:eav_attribute} |
|
119
|
|
|
WHERE attribute_code = \'url_path\' AND entity_type_id = 3 |
|
120
|
|
|
) |
|
121
|
|
|
AND url_path_store.store_id = :store_id |
|
122
|
|
|
AND url_path_store.entity_id = t0.entity_id |
|
123
|
|
|
LEFT JOIN ${table:catalog_category_entity_varchar} AS url_path_default |
|
124
|
|
|
ON url_path_default.attribute_id = ( |
|
125
|
|
|
SELECT attribute_id FROM ${table:eav_attribute} |
|
126
|
|
|
WHERE attribute_code = \'url_path\' AND entity_type_id = 3 |
|
127
|
|
|
) |
|
128
|
|
|
AND url_path_default.store_id = 0 |
|
129
|
|
|
AND url_path_default.entity_id = t0.entity_id |
|
130
|
|
|
LEFT JOIN ${table:catalog_category_entity_int} AS is_anchor_store |
|
131
|
|
|
ON is_anchor_store.attribute_id = ( |
|
132
|
|
|
SELECT attribute_id FROM ${table:eav_attribute} |
|
133
|
|
|
WHERE attribute_code = \'is_anchor\' AND entity_type_id = 3 |
|
134
|
|
|
) |
|
135
|
|
|
AND is_anchor_store.store_id = :store_id |
|
136
|
|
|
AND is_anchor_store.entity_id = t0.entity_id |
|
137
|
|
|
LEFT JOIN ${table:catalog_category_entity_int} AS is_anchor_default |
|
138
|
|
|
ON is_anchor_default.attribute_id = ( |
|
139
|
|
|
SELECT attribute_id FROM ${table:eav_attribute} |
|
140
|
|
|
WHERE attribute_code = \'is_anchor\' AND entity_type_id = 3 |
|
141
|
|
|
) |
|
142
|
|
|
AND is_anchor_default.store_id = 0 |
|
143
|
|
|
AND is_anchor_default.entity_id = t0.entity_id', |
|
144
|
|
|
SqlStatementKeys::ROOT_CATEGORIES => |
|
145
|
|
|
'SELECT t2.code, t0.* |
|
146
|
|
|
FROM ${table:catalog_category_entity} t0 |
|
147
|
|
|
INNER JOIN ${table:store_group} t1 |
|
148
|
|
|
ON t1.root_category_id = t0.entity_id |
|
149
|
|
|
INNER JOIN ${table:store} t2 |
|
150
|
|
|
ON t2.group_id = t1.group_id', |
|
151
|
|
|
SqlStatementKeys::CATEGORY_VARCHARS_BY_ENTITY_IDS => |
|
152
|
|
|
'SELECT t1.* |
|
153
|
|
|
FROM ${table:catalog_category_entity_varchar} AS t1 |
|
154
|
|
|
INNER JOIN ${table:eav_attribute} AS t2 |
|
155
|
|
|
ON t2.entity_type_id = 3 |
|
156
|
|
|
AND t2.attribute_code = \'name\' |
|
157
|
|
|
AND t1.attribute_id = t2.attribute_id |
|
158
|
|
|
AND t1.store_id = 0 |
|
159
|
|
|
AND t1.entity_id IN (?)', |
|
160
|
|
|
SqlStatementKeys::STORES => |
|
161
|
|
|
'SELECT t1.* FROM ${table:store} AS t1', |
|
162
|
|
|
SqlStatementKeys::STORE_DEFAULT => |
|
163
|
|
|
'SELECT t0.* |
|
164
|
|
|
FROM ${table:store} t0 |
|
165
|
|
|
INNER JOIN ${table:store_group} t1 |
|
166
|
|
|
ON t1.default_store_id = t0.store_id |
|
167
|
|
|
INNER JOIN ${table:store_website} t2 |
|
168
|
|
|
ON t1.website_id = t2.website_id |
|
169
|
|
|
AND t2.is_default = 1;', |
|
170
|
|
|
SqlStatementKeys::STORE_WEBSITES => |
|
171
|
|
|
'SELECT t1.* FROM ${table:store_website} AS t1', |
|
172
|
|
|
SqlStatementKeys::STORE_GROUPS => |
|
173
|
|
|
'SELECT t1.* FROM ${table:store_group} AS t1', |
|
174
|
|
|
SqlStatementKeys::TAX_CLASSES => |
|
175
|
|
|
'SELECT t1.* FROM ${table:tax_class} AS t1', |
|
176
|
|
|
SqlStatementKeys::LINK_TYPES => |
|
177
|
|
|
'SELECT t1.* FROM ${table:catalog_product_link_type} AS t1', |
|
178
|
|
|
SqlStatementKeys::LINK_ATTRIBUTES => |
|
179
|
|
|
'SELECT t1.* FROM ${table:catalog_product_link_attribute} AS t1', |
|
180
|
|
|
SqlStatementKeys::EAV_ENTITY_TYPES => |
|
181
|
|
|
'SELECT t1.* FROM ${table:eav_entity_type} AS t1', |
|
182
|
|
|
SqlStatementKeys::EAV_ENTITY_TYPE_BY_ENTITY_TYPE_CODE => |
|
183
|
|
|
'SELECT * |
|
184
|
|
|
FROM ${table:eav_entity_type} |
|
185
|
|
|
WHERE entity_type_code = :entity_type_code', |
|
186
|
|
|
SqlStatementKeys::EAV_ATTRIBUTE => |
|
187
|
|
|
'SELECT * |
|
188
|
|
|
FROM ${table:eav_attribute} |
|
189
|
|
|
WHERE attribute_id = :attribute_id', |
|
190
|
|
|
SqlStatementKeys::EAV_ATTRIBUTE_SET => |
|
191
|
|
|
'SELECT t1.* |
|
192
|
|
|
FROM ${table:eav_attribute_set} AS t1 |
|
193
|
|
|
WHERE attribute_set_id = ?', |
|
194
|
|
|
SqlStatementKeys::EAV_ATTRIBUTE_GROUP => |
|
195
|
|
|
'SELECT t1.* |
|
196
|
|
|
FROM ${table:eav_attribute_group} AS t1 |
|
197
|
|
|
WHERE attribute_group_id = :attribute_group_id', |
|
198
|
|
|
SqlStatementKeys::EAV_ATTRIBUTE_GROUP_BY_ENTITY_TYPE_CODE_AND_ATTRIBUTE_SET_NAME_AND_ATTRIBUTE_GROUP_NAME => |
|
199
|
|
|
'SELECT t1.* |
|
200
|
|
|
FROM ${table:eav_attribute_group} AS t1 |
|
201
|
|
|
INNER JOIN ${table:eav_entity_type} t3 |
|
202
|
|
|
ON t3.entity_type_code = :entity_type_code |
|
203
|
|
|
INNER JOIN ${table:eav_attribute_set} t2 |
|
204
|
|
|
ON t2.attribute_set_name = :attribute_set_name |
|
205
|
|
|
AND t2.entity_type_id = t3.entity_type_id |
|
206
|
|
|
AND t1.attribute_set_id = t2.attribute_set_id |
|
207
|
|
|
WHERE attribute_group_name = :attribute_group_name', |
|
208
|
|
|
SqlStatementKeys::EAV_ATTRIBUTE_SETS_BY_ENTITY_TYPE_ID => |
|
209
|
|
|
'SELECT t1.* |
|
210
|
|
|
FROM ${table:eav_attribute_set} AS t1 |
|
211
|
|
|
WHERE entity_type_id = ?', |
|
212
|
|
|
SqlStatementKeys::EAV_ATTRIBUTE_SET_BY_ENTITY_TYPE_CODE_AND_ATTRIBUTE_SET_NAME => |
|
213
|
|
|
'SELECT t1.* |
|
214
|
|
|
FROM ${table:eav_attribute_set} AS t1 |
|
215
|
|
|
INNER JOIN ${table:eav_entity_type} t2 |
|
216
|
|
|
ON t2.entity_type_code = :entity_type_code |
|
217
|
|
|
AND t1.entity_type_id = t2.entity_type_id |
|
218
|
|
|
WHERE t1.attribute_set_name = :attribute_set_name', |
|
219
|
|
|
SqlStatementKeys::EAV_ATTRIBUTE_SET_BY_ENTITY_TYPE_ID_AND_ATTRIBUTE_SET_NAME => |
|
220
|
|
|
'SELECT * |
|
221
|
|
|
FROM ${table:eav_attribute_set} |
|
222
|
|
|
WHERE entity_type_id = :entity_type_id |
|
223
|
|
|
AND attribute_set_name = :attribute_set_name', |
|
224
|
|
|
SqlStatementKeys::EAV_ATTRIBUTE_GROUPS_BY_ATTRIBUTE_SET_ID => |
|
225
|
|
|
'SELECT * |
|
226
|
|
|
FROM ${table:eav_attribute_group} |
|
227
|
|
|
WHERE attribute_set_id = :attribute_set_id', |
|
228
|
|
|
SqlStatementKeys::EAV_ATTRIBUTE_BY_ENTITY_TYPE_ID_AND_ATTRIBUTE_CODE => |
|
229
|
|
|
'SELECT * |
|
230
|
|
|
FROM ${table:eav_attribute} |
|
231
|
|
|
WHERE entity_type_id = :entity_type_id |
|
232
|
|
|
AND attribute_code = :attribute_code', |
|
233
|
|
|
SqlStatementKeys::EAV_ATTRIBUTES_BY_ENTITY_TYPE_ID_AND_ATTRIBUTE_SET_NAME => |
|
234
|
|
|
'SELECT t3.* |
|
235
|
|
|
FROM ${table:eav_attribute} AS t3 |
|
236
|
|
|
INNER JOIN ${table:eav_entity_type} AS t0 |
|
237
|
|
|
ON t0.entity_type_id = :entity_type_id |
|
238
|
|
|
INNER JOIN ${table:eav_attribute_set} AS t1 |
|
239
|
|
|
ON t1.attribute_set_name = :attribute_set_name |
|
240
|
|
|
AND t1.entity_type_id = t0.entity_type_id |
|
241
|
|
|
INNER JOIN ${table:eav_entity_attribute} AS t2 |
|
242
|
|
|
ON t2.attribute_set_id = t1.attribute_set_id |
|
243
|
|
|
AND t3.attribute_id = t2.attribute_id', |
|
244
|
|
|
SqlStatementKeys::EAV_ATTRIBUTES_BY_OPTION_VALUE_AND_STORE_ID => |
|
245
|
|
|
'SELECT t1.* |
|
246
|
|
|
FROM ${table:eav_attribute} AS t1 |
|
247
|
|
|
INNER JOIN ${table:eav_attribute_option_value} AS t2 |
|
248
|
|
|
ON t2.value = BINARY :value |
|
249
|
|
|
AND t2.store_id = :store_id |
|
250
|
|
|
INNER JOIN ${table:eav_attribute_option} AS t3 |
|
251
|
|
|
ON t3.option_id = t2.option_id |
|
252
|
|
|
AND t1.attribute_id = t3.attribute_id', |
|
253
|
|
|
SqlStatementKeys::EAV_ATTRIBUTES_BY_IS_USER_DEFINED => |
|
254
|
|
|
'SELECT * FROM ${table:eav_attribute} WHERE is_user_defined = :is_user_defined', |
|
255
|
|
|
SqlStatementKeys::EAV_ATTRIBUTES_BY_ENTITY_TYPE_ID_AND_IS_USER_DEFINED => |
|
256
|
|
|
'SELECT * |
|
257
|
|
|
FROM ${table:eav_attribute} |
|
258
|
|
|
WHERE entity_type_id = :entity_type_id |
|
259
|
|
|
AND is_user_defined = :is_user_defined', |
|
260
|
|
|
SqlStatementKeys::EAV_ATTRIBUTE_OPTION_VALUE_BY_ATTRIBUTE_CODE_AND_STORE_ID_AND_VALUE => |
|
261
|
|
|
'SELECT t3.* |
|
262
|
|
|
FROM ${table:eav_attribute} t1, |
|
263
|
|
|
${table:eav_attribute_option} t2, |
|
264
|
|
|
${table:eav_attribute_option_value} t3 |
|
265
|
|
|
WHERE t1.attribute_code = :attribute_code |
|
266
|
|
|
AND t3.store_id = :store_id |
|
267
|
|
|
AND t3.value = BINARY :value |
|
268
|
|
|
AND t2.attribute_id = t1.attribute_id |
|
269
|
|
|
AND t2.option_id = t3.option_id', |
|
270
|
|
|
SqlStatementKeys::EAV_ATTRIBUTE_OPTION_VALUE_BY_ENTITY_TYPE_ID_AND_ATTRIBUTE_CODE_AND_STORE_ID_AND_VALUE => |
|
271
|
|
|
'SELECT t3.* |
|
272
|
|
|
FROM ${table:eav_attribute} t1, |
|
273
|
|
|
${table:eav_attribute_option} t2, |
|
274
|
|
|
${table:eav_attribute_option_value} t3 |
|
275
|
|
|
WHERE t1.attribute_code = :attribute_code |
|
276
|
|
|
AND t1.entity_type_id = :entity_type_id |
|
277
|
|
|
AND t3.store_id = :store_id |
|
278
|
|
|
AND t3.value = BINARY :value |
|
279
|
|
|
AND t2.attribute_id = t1.attribute_id |
|
280
|
|
|
AND t2.option_id = t3.option_id', |
|
281
|
|
|
SqlStatementKeys::EAV_ATTRIBUTE_OPTION_VALUE_BY_OPTION_ID_AND_STORE_ID => |
|
282
|
|
|
'SELECT t1.* |
|
283
|
|
|
FROM ${table:eav_attribute_option_value} t1 |
|
284
|
|
|
WHERE t1.option_id = :option_id |
|
285
|
|
|
AND t1.store_id = :store_id', |
|
286
|
|
|
SqlStatementKeys::EAV_ATTRIBUTE_OPTION_VALUES => |
|
287
|
|
|
'SELECT t3.*, t1.attribute_code |
|
288
|
|
|
FROM ${table:eav_attribute} t1, |
|
289
|
|
|
${table:eav_attribute_option} t2, |
|
290
|
|
|
${table:eav_attribute_option_value} t3 |
|
291
|
|
|
WHERE t2.option_id = t3.option_id |
|
292
|
|
|
AND t1.attribute_id = t2.attribute_id', |
|
293
|
|
|
SqlStatementKeys::EAV_ATTRIBUTE_OPTION_VALUES_BY_ENTITY_TYPE_ID_AND_STORE_ID => |
|
294
|
|
|
'SELECT t3.*, t1.attribute_code |
|
295
|
|
|
FROM ${table:eav_attribute} t1, |
|
296
|
|
|
${table:eav_attribute_option} t2, |
|
297
|
|
|
${table:eav_attribute_option_value} t3 |
|
298
|
|
|
WHERE t2.option_id = t3.option_id |
|
299
|
|
|
AND t1.attribute_id = t2.attribute_id |
|
300
|
|
|
AND t1.entity_type_id = :entity_type_id |
|
301
|
|
|
AND t3.store_id = :store_id', |
|
302
|
|
|
SqlStatementKeys::CORE_CONFIG_DATA => |
|
303
|
|
|
'SELECT * FROM ${table:core_config_data}', |
|
304
|
|
|
SqlStatementKeys::URL_REWRITES_BY_ENTITY_TYPE_AND_ENTITY_ID => |
|
305
|
|
|
'SELECT * |
|
306
|
|
|
FROM ${table:url_rewrite} |
|
307
|
|
|
WHERE entity_type = :entity_type |
|
308
|
|
|
AND entity_id = :entity_id', |
|
309
|
|
|
SqlStatementKeys::URL_REWRITES_BY_ENTITY_TYPE_AND_ENTITY_ID_AND_STORE_ID => |
|
310
|
|
|
'SELECT * |
|
311
|
|
|
FROM ${table:url_rewrite} |
|
312
|
|
|
WHERE entity_type = :entity_type |
|
313
|
|
|
AND entity_id = :entity_id |
|
314
|
|
|
AND store_id = :store_id', |
|
315
|
|
|
SqlStatementKeys::DELETE_URL_REWRITE => |
|
316
|
|
|
'DELETE |
|
317
|
|
|
FROM ${table:url_rewrite} |
|
318
|
|
|
WHERE url_rewrite_id = :url_rewrite_id', |
|
319
|
|
|
SqlStatementKeys::DELETE_URL_REWRITE_BY_SKU => |
|
320
|
|
|
'DELETE t1.* |
|
321
|
|
|
FROM ${table:url_rewrite} t1 |
|
322
|
|
|
INNER JOIN ${table:catalog_product_entity} t2 |
|
323
|
|
|
WHERE t2.sku = :sku |
|
324
|
|
|
AND t1.entity_id = t2.entity_id', |
|
325
|
|
|
SqlStatementKeys::DELETE_URL_REWRITE_BY_PATH => |
|
326
|
|
|
'DELETE t1.* |
|
327
|
|
|
FROM ${table:url_rewrite} t1 |
|
328
|
|
|
INNER JOIN ${table:catalog_category_entity} t2 |
|
329
|
|
|
WHERE t2.path = :path |
|
330
|
|
|
AND t1.entity_id = t2.entity_id |
|
331
|
|
|
AND t1.entity_type = \'category\'', |
|
332
|
|
|
SqlStatementKeys::DELETE_URL_REWRITE_BY_CATEGORY_ID => |
|
333
|
|
|
'DELETE t1.* |
|
334
|
|
|
FROM ${table:url_rewrite} t1 |
|
335
|
|
|
INNER JOIN ${table:catalog_url_rewrite_product_category} t2 |
|
336
|
|
|
WHERE t2.category_id = :category_id |
|
337
|
|
|
AND t1.url_rewrite_id = t2.url_rewrite_id', |
|
338
|
|
|
SqlStatementKeys::CREATE_URL_REWRITE => |
|
339
|
|
|
'INSERT |
|
340
|
|
|
INTO ${table:url_rewrite} |
|
341
|
|
|
(entity_type, |
|
342
|
|
|
entity_id, |
|
343
|
|
|
request_path, |
|
344
|
|
|
target_path, |
|
345
|
|
|
redirect_type, |
|
346
|
|
|
store_id, |
|
347
|
|
|
description, |
|
348
|
|
|
is_autogenerated, |
|
349
|
|
|
metadata) |
|
350
|
|
|
VALUES (:entity_type, |
|
351
|
|
|
:entity_id, |
|
352
|
|
|
:request_path, |
|
353
|
|
|
:target_path, |
|
354
|
|
|
:redirect_type, |
|
355
|
|
|
:store_id, |
|
356
|
|
|
:description, |
|
357
|
|
|
:is_autogenerated, |
|
358
|
|
|
:metadata)', |
|
359
|
|
|
SqlStatementKeys::UPDATE_URL_REWRITE => |
|
360
|
|
|
'UPDATE ${table:url_rewrite} |
|
361
|
|
|
SET entity_type = :entity_type, |
|
362
|
|
|
entity_id = :entity_id, |
|
363
|
|
|
request_path = :request_path, |
|
364
|
|
|
target_path = :target_path, |
|
365
|
|
|
redirect_type = :redirect_type, |
|
366
|
|
|
store_id = :store_id, |
|
367
|
|
|
description = :description, |
|
368
|
|
|
is_autogenerated = :is_autogenerated, |
|
369
|
|
|
metadata = :metadata |
|
370
|
|
|
WHERE url_rewrite_id = :url_rewrite_id', |
|
371
|
|
|
SqlStatementKeys::CREATE_STORE => |
|
372
|
|
|
'INSERT |
|
373
|
|
|
INTO ${table:store} |
|
374
|
|
|
(code, |
|
375
|
|
|
website_id, |
|
376
|
|
|
group_id, |
|
377
|
|
|
name, |
|
378
|
|
|
sort_order, |
|
379
|
|
|
is_active) |
|
380
|
|
|
VALUES (:code, |
|
381
|
|
|
:website_id, |
|
382
|
|
|
:group_id, |
|
383
|
|
|
:name, |
|
384
|
|
|
:sort_order, |
|
385
|
|
|
:is_active)', |
|
386
|
|
|
SqlStatementKeys::UPDATE_STORE => |
|
387
|
|
|
'UPDATE ${table:store} |
|
388
|
|
|
SET code = :code, |
|
389
|
|
|
website_id = :website_id, |
|
390
|
|
|
group_id = :group_id, |
|
391
|
|
|
name = :name, |
|
392
|
|
|
sort_order = :sort_order, |
|
393
|
|
|
is_active = :is_active |
|
394
|
|
|
WHERE store_id = :store_id', |
|
395
|
|
|
SqlStatementKeys::CREATE_STORE_GROUP => |
|
396
|
|
|
'INSERT |
|
397
|
|
|
INTO ${table:store_group} |
|
398
|
|
|
(website_id, |
|
399
|
|
|
name, |
|
400
|
|
|
root_category_id, |
|
401
|
|
|
default_store_id) |
|
402
|
|
|
VALUES (:website_id, |
|
403
|
|
|
:name, |
|
404
|
|
|
:root_category_id, |
|
405
|
|
|
:default_store_id)', |
|
406
|
|
|
SqlStatementKeys::UPDATE_STORE_GROUP => |
|
407
|
|
|
'UPDATE ${table:store_group} |
|
408
|
|
|
SET website_id = :website_id, |
|
409
|
|
|
name = :name, |
|
410
|
|
|
root_category_id = :root_category_id, |
|
411
|
|
|
default_store_id = :default_store_id |
|
412
|
|
|
WHERE group_id = :group_id', |
|
413
|
|
|
SqlStatementKeys::CREATE_STORE_WEBSITE => |
|
414
|
|
|
'INSERT |
|
415
|
|
|
INTO ${table:store_website} |
|
416
|
|
|
(code, |
|
417
|
|
|
name, |
|
418
|
|
|
sort_order, |
|
419
|
|
|
default_group_id, |
|
420
|
|
|
is_default) |
|
421
|
|
|
VALUES (:code, |
|
422
|
|
|
:name, |
|
423
|
|
|
:sort_order, |
|
424
|
|
|
:default_group_id, |
|
425
|
|
|
:is_default)', |
|
426
|
|
|
SqlStatementKeys::UPDATE_STORE_WEBSITE => |
|
427
|
|
|
'UPDATE ${table:store_website} |
|
428
|
|
|
SET code = :code, |
|
429
|
|
|
name = :name, |
|
430
|
|
|
sort_order = :sort_order, |
|
431
|
|
|
default_group_id = :default_group_id, |
|
432
|
|
|
is_default = :is_default |
|
433
|
|
|
WHERE website_id = :website_id', |
|
434
|
|
|
SqlStatementKeys::IMAGE_TYPES => |
|
435
|
|
|
'SELECT main_table.attribute_code, |
|
436
|
|
|
main_table.attribute_id, |
|
437
|
|
|
main_table.is_user_defined |
|
438
|
|
|
FROM ${table:eav_attribute} AS main_table |
|
439
|
|
|
INNER JOIN ${table:eav_entity_type} AS entity_type |
|
440
|
|
|
ON main_table.entity_type_id = entity_type.entity_type_id |
|
441
|
|
|
LEFT JOIN ${table:eav_entity_attribute} |
|
442
|
|
|
ON main_table.attribute_id = ${table:eav_entity_attribute}.attribute_id |
|
443
|
|
|
INNER JOIN ${table:catalog_eav_attribute} AS additional_table |
|
444
|
|
|
ON main_table.attribute_id = additional_table.attribute_id |
|
445
|
|
|
WHERE (entity_type_code = \'catalog_product\') |
|
446
|
|
|
AND (frontend_input = \'media_image\') |
|
447
|
|
|
GROUP BY main_table.attribute_code, |
|
448
|
|
|
main_table.attribute_id, |
|
449
|
|
|
main_table.is_user_defined |
|
450
|
|
|
ORDER BY main_table.is_user_defined, |
|
451
|
|
|
main_table.attribute_id', |
|
452
|
|
|
SqlStatementKeys::CUSTOMER_GROUPS => |
|
453
|
|
|
'SELECT * FROM ${table:customer_group}', |
|
454
|
|
|
SqlStatementKeys::DELETE_IMPORT_HISTORY => |
|
455
|
|
|
'DELETE |
|
456
|
|
|
FROM ${table:import_history} |
|
457
|
|
|
WHERE history_id = :history_id', |
|
458
|
|
|
SqlStatementKeys::UPDATE_IMPORT_HISTORY => |
|
459
|
|
|
'UPDATE ${table:import_history} |
|
460
|
|
|
SET user_id = :user_id, |
|
461
|
|
|
started_at = :started_at, |
|
462
|
|
|
imported_file = :imported_file, |
|
463
|
|
|
execution_time = :execution_time, |
|
464
|
|
|
summary = :summary, |
|
465
|
|
|
error_file = :error_file |
|
466
|
|
|
WHERE history_id = :history_id', |
|
467
|
|
|
SqlStatementKeys::CREATE_IMPORT_HISTORY => |
|
468
|
|
|
'INSERT |
|
469
|
|
|
INTO ${table:import_history} |
|
470
|
|
|
(user_id, |
|
471
|
|
|
started_at, |
|
472
|
|
|
imported_file, |
|
473
|
|
|
execution_time, |
|
474
|
|
|
summary, |
|
475
|
|
|
error_file) |
|
476
|
|
|
VALUES (:user_id, |
|
477
|
|
|
:started_at, |
|
478
|
|
|
:imported_file, |
|
479
|
|
|
:execution_time, |
|
480
|
|
|
:summary, |
|
481
|
|
|
:error_file)', |
|
482
|
|
|
SqlStatementKeys::ADMIN_USERS => |
|
483
|
|
|
'SELECT * |
|
484
|
|
|
FROM ${table:admin_user}', |
|
485
|
|
|
SqlStatementKeys::ADMIN_USER_BY_USERNAME => |
|
486
|
|
|
'SELECT * |
|
487
|
|
|
FROM ${table:admin_user} |
|
488
|
|
|
WHERE username = :username' |
|
489
|
|
|
); |
|
490
|
|
|
|
|
491
|
|
|
/** |
|
492
|
|
|
* Initializes the SQL statement repository with the primary key and table prefix utility. |
|
493
|
|
|
* |
|
494
|
|
|
* @param \TechDivision\Import\Utils\SqlCompilerInterface[] $compilers The array with the compiler instances |
|
495
|
|
|
*/ |
|
496
|
2 |
|
public function __construct(\IteratorAggregate $compilers) |
|
497
|
|
|
{ |
|
498
|
|
|
|
|
499
|
|
|
// pass primary key + table prefix utility to parent instance |
|
500
|
2 |
|
parent::__construct($compilers); |
|
501
|
|
|
|
|
502
|
|
|
// compile the SQL statements |
|
503
|
2 |
|
$this->compile($this->statements); |
|
504
|
2 |
|
} |
|
505
|
|
|
} |
|
506
|
|
|
|