|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* TechDivision\Import\Product\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-product |
|
18
|
|
|
* @link http://www.techdivision.com |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace TechDivision\Import\Product\Utils; |
|
22
|
|
|
|
|
23
|
|
|
use TechDivision\Import\Utils\SqlStatements as FallbackStatements; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Utility 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-product |
|
32
|
|
|
* @link http://www.techdivision.com |
|
33
|
|
|
*/ |
|
34
|
|
|
class SqlStatements extends FallbackStatements |
|
35
|
|
|
{ |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* The SQL statement to create new products. |
|
39
|
|
|
* |
|
40
|
|
|
* @var string |
|
41
|
|
|
*/ |
|
42
|
|
|
const CREATE_PRODUCT = 'INSERT |
|
43
|
|
|
INTO catalog_product_entity ( |
|
44
|
|
|
sku, |
|
45
|
|
|
created_at, |
|
46
|
|
|
updated_at, |
|
47
|
|
|
has_options, |
|
48
|
|
|
required_options, |
|
49
|
|
|
type_id, |
|
50
|
|
|
attribute_set_id |
|
51
|
|
|
) |
|
52
|
|
|
VALUES (?, ?, ?, ?, ?, ?, ?)'; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* The SQL statement to create a new product website relation. |
|
56
|
|
|
* |
|
57
|
|
|
* @var string |
|
58
|
|
|
*/ |
|
59
|
|
|
const CREATE_PRODUCT_WEBSITE = 'INSERT |
|
60
|
|
|
INTO catalog_product_website ( |
|
61
|
|
|
product_id, |
|
62
|
|
|
website_id |
|
63
|
|
|
) |
|
64
|
|
|
VALUES (?, ?)'; |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* The SQL statement to create a new product category relation. |
|
68
|
|
|
* |
|
69
|
|
|
* @var string |
|
70
|
|
|
*/ |
|
71
|
|
|
const CREATE_PRODUCT_CATEGORY = 'INSERT |
|
72
|
|
|
INTO catalog_category_product ( |
|
73
|
|
|
category_id, |
|
74
|
|
|
product_id, |
|
75
|
|
|
position |
|
76
|
|
|
) |
|
77
|
|
|
VALUES (?, ?, ?)'; |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* The SQL statement to create a new product datetime value. |
|
81
|
|
|
* |
|
82
|
|
|
* @var string |
|
83
|
|
|
*/ |
|
84
|
|
|
const CREATE_PRODUCT_DATETIME = 'INSERT |
|
85
|
|
|
INTO catalog_product_entity_datetime ( |
|
86
|
|
|
entity_id, |
|
87
|
|
|
attribute_id, |
|
88
|
|
|
store_id, |
|
89
|
|
|
value |
|
90
|
|
|
) |
|
91
|
|
|
VALUES (?, ?, ?, ?)'; |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* The SQL statement to create a new product decimal value. |
|
95
|
|
|
* |
|
96
|
|
|
* @var string |
|
97
|
|
|
*/ |
|
98
|
|
|
const CREATE_PRODUCT_DECIMAL = 'INSERT |
|
99
|
|
|
INTO catalog_product_entity_decimal ( |
|
100
|
|
|
entity_id, |
|
101
|
|
|
attribute_id, |
|
102
|
|
|
store_id, |
|
103
|
|
|
value |
|
104
|
|
|
) |
|
105
|
|
|
VALUES (?, ?, ?, ?)'; |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* The SQL statement to create a new product integer value. |
|
109
|
|
|
* |
|
110
|
|
|
* @var string |
|
111
|
|
|
*/ |
|
112
|
|
|
const CREATE_PRODUCT_INT = 'INSERT |
|
113
|
|
|
INTO catalog_product_entity_int ( |
|
114
|
|
|
entity_id, |
|
115
|
|
|
attribute_id, |
|
116
|
|
|
store_id, |
|
117
|
|
|
value |
|
118
|
|
|
) |
|
119
|
|
|
VALUES (?, ?, ?, ?)'; |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* The SQL statement to create a new product varchar value. |
|
123
|
|
|
* |
|
124
|
|
|
* @var string |
|
125
|
|
|
*/ |
|
126
|
|
|
const CREATE_PRODUCT_VARCHAR = 'INSERT |
|
127
|
|
|
INTO catalog_product_entity_varchar ( |
|
128
|
|
|
entity_id, |
|
129
|
|
|
attribute_id, |
|
130
|
|
|
store_id, |
|
131
|
|
|
value |
|
132
|
|
|
) |
|
133
|
|
|
VALUES (?, ?, ?, ?)'; |
|
134
|
|
|
|
|
135
|
|
|
/** |
|
136
|
|
|
* The SQL statement to create a new product text value. |
|
137
|
|
|
* |
|
138
|
|
|
* @var string |
|
139
|
|
|
*/ |
|
140
|
|
|
const CREATE_PRODUCT_TEXT = 'INSERT |
|
141
|
|
|
INTO catalog_product_entity_text ( |
|
142
|
|
|
entity_id, |
|
143
|
|
|
attribute_id, |
|
144
|
|
|
store_id, |
|
145
|
|
|
value |
|
146
|
|
|
) |
|
147
|
|
|
VALUES (?, ?, ?, ?)'; |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* The SQL statement to create a product's stock status. |
|
151
|
|
|
* |
|
152
|
|
|
* @var string |
|
153
|
|
|
*/ |
|
154
|
|
|
const CREATE_STOCK_STATUS = 'INSERT |
|
155
|
|
|
INTO cataloginventory_stock_status ( |
|
156
|
|
|
product_id, |
|
157
|
|
|
website_id, |
|
158
|
|
|
stock_id, |
|
159
|
|
|
qty, |
|
160
|
|
|
stock_status |
|
161
|
|
|
) |
|
162
|
|
|
VALUES (?, ?, ?, ?, ?)'; |
|
163
|
|
|
|
|
164
|
|
|
/** |
|
165
|
|
|
* The SQL statement to create a product's stock status. |
|
166
|
|
|
* |
|
167
|
|
|
* @var string |
|
168
|
|
|
*/ |
|
169
|
|
|
const CREATE_STOCK_ITEM = 'INSERT |
|
170
|
|
|
INTO cataloginventory_stock_item ( |
|
171
|
|
|
product_id, |
|
172
|
|
|
stock_id, |
|
173
|
|
|
website_id, |
|
174
|
|
|
qty, |
|
175
|
|
|
min_qty, |
|
176
|
|
|
use_config_min_qty, |
|
177
|
|
|
is_qty_decimal, |
|
178
|
|
|
backorders, |
|
179
|
|
|
use_config_backorders, |
|
180
|
|
|
min_sale_qty, |
|
181
|
|
|
use_config_min_sale_qty, |
|
182
|
|
|
max_sale_qty, |
|
183
|
|
|
use_config_max_sale_qty, |
|
184
|
|
|
is_in_stock, |
|
185
|
|
|
notify_stock_qty, |
|
186
|
|
|
use_config_notify_stock_qty, |
|
187
|
|
|
manage_stock, |
|
188
|
|
|
use_config_manage_stock, |
|
189
|
|
|
use_config_qty_increments, |
|
190
|
|
|
qty_increments, |
|
191
|
|
|
use_config_enable_qty_inc, |
|
192
|
|
|
enable_qty_increments, |
|
193
|
|
|
is_decimal_divided |
|
194
|
|
|
) |
|
195
|
|
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; |
|
196
|
|
|
|
|
197
|
|
|
/** |
|
198
|
|
|
* The SQL statement to create new URL rewrites. |
|
199
|
|
|
* |
|
200
|
|
|
* @var string |
|
201
|
|
|
*/ |
|
202
|
|
|
const CREATE_URL_REWRITE = 'INSERT |
|
203
|
|
|
INTO url_rewrite ( |
|
204
|
|
|
entity_type, |
|
205
|
|
|
entity_id, |
|
206
|
|
|
request_path, |
|
207
|
|
|
target_path, |
|
208
|
|
|
redirect_type, |
|
209
|
|
|
store_id, |
|
210
|
|
|
description, |
|
211
|
|
|
is_autogenerated, |
|
212
|
|
|
metadata |
|
213
|
|
|
) |
|
214
|
|
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)'; |
|
215
|
|
|
|
|
216
|
|
|
/** |
|
217
|
|
|
* The SQL statement to remove a existing product. |
|
218
|
|
|
* |
|
219
|
|
|
* @var string |
|
220
|
|
|
*/ |
|
221
|
|
|
const REMOVE_PRODUCT = 'DELETE |
|
222
|
|
|
FROM catalog_product_entity |
|
223
|
|
|
WHERE sku = ?'; |
|
224
|
|
|
|
|
225
|
|
|
/** |
|
226
|
|
|
* The SQL statement to remove a existing URL rewrite. |
|
227
|
|
|
* |
|
228
|
|
|
* @var string |
|
229
|
|
|
*/ |
|
230
|
|
|
const REMOVE_URL_REWRITE = 'DELETE |
|
231
|
|
|
FROM url_rewrite |
|
232
|
|
|
WHERE url_rewrite_id = ?'; |
|
233
|
|
|
|
|
234
|
|
|
/** |
|
235
|
|
|
* The SQL statement to remove all existing URL rewrites related with the SKU passed as parameter. |
|
236
|
|
|
* |
|
237
|
|
|
* @var string |
|
238
|
|
|
*/ |
|
239
|
|
|
const REMOVE_URL_REWRITE_BY_SKU = 'DELETE url_rewrite |
|
240
|
|
|
FROM url_rewrite |
|
241
|
|
|
INNER JOIN catalog_product_entity |
|
242
|
|
|
WHERE catalog_product_entity.sku = ? |
|
243
|
|
|
AND url_rewrite.entity_id = catalog_product_entity.entity_id'; |
|
244
|
|
|
|
|
245
|
|
|
/** |
|
246
|
|
|
* The SQL statement to remove all existing stock status related with the SKU passed as parameter. |
|
247
|
|
|
* |
|
248
|
|
|
* @var string |
|
249
|
|
|
*/ |
|
250
|
|
|
const REMOVE_STOCK_STATUS_BY_SKU = 'DELETE cataloginventory_stock_status |
|
251
|
|
|
FROM cataloginventory_stock_status |
|
252
|
|
|
INNER JOIN catalog_product_entity |
|
253
|
|
|
WHERE catalog_product_entity.sku = ? |
|
254
|
|
|
AND cataloginventory_stock_status.product_id = catalog_product_entity.entity_id'; |
|
255
|
|
|
|
|
256
|
|
|
/** |
|
257
|
|
|
* The SQL statement to remove all existing stock item related with the SKU passed as parameter. |
|
258
|
|
|
* |
|
259
|
|
|
* @var string |
|
260
|
|
|
*/ |
|
261
|
|
|
const REMOVE_STOCK_ITEM_BY_SKU = 'DELETE cataloginventory_stock_item |
|
262
|
|
|
FROM cataloginventory_stock_item |
|
263
|
|
|
INNER JOIN catalog_product_entity |
|
264
|
|
|
WHERE catalog_product_entity.sku = ? |
|
265
|
|
|
AND cataloginventory_stock_item.product_id = catalog_product_entity.entity_id'; |
|
266
|
|
|
|
|
267
|
|
|
/** |
|
268
|
|
|
* The SQL statement to remove all product website relations for the product with the SKU passed as parameter. |
|
269
|
|
|
* |
|
270
|
|
|
* @var string |
|
271
|
|
|
*/ |
|
272
|
|
|
const REMOVE_PRODUCT_WEBSITE_BY_SKU = 'DELETE catalog_product_website |
|
273
|
|
|
FROM catalog_product_website |
|
274
|
|
|
INNER JOIN catalog_product_entity |
|
275
|
|
|
WHERE catalog_product_entity.sku = ? |
|
276
|
|
|
AND catalog_product_website.product_id = catalog_product_entity.entity_id'; |
|
277
|
|
|
|
|
278
|
|
|
/** |
|
279
|
|
|
* The SQL statement to remove all product category relations for the product with the SKU passed as parameter. |
|
280
|
|
|
* |
|
281
|
|
|
* @var string |
|
282
|
|
|
*/ |
|
283
|
|
|
const REMOVE_PRODUCT_CATEGORY_BY_SKU = 'DELETE catalog_category_product |
|
284
|
|
|
FROM catalog_category_product |
|
285
|
|
|
INNER JOIN catalog_product_entity |
|
286
|
|
|
WHERE catalog_product_entity.sku = ? |
|
287
|
|
|
AND catalog_category_product.product_id = catalog_product_entity.entity_id'; |
|
288
|
|
|
|
|
289
|
|
|
/** |
|
290
|
|
|
* The SQL statement to load the URL rewrites for the passed entity type and ID. |
|
291
|
|
|
* |
|
292
|
|
|
* @var string |
|
293
|
|
|
*/ |
|
294
|
|
|
const URL_REWRITES_BY_ENTITY_TYPE_AND_ENTITY_ID = 'SELECT * |
|
295
|
|
|
FROM url_rewrite |
|
296
|
|
|
WHERE entity_type = ? |
|
297
|
|
|
AND entity_id = ?'; |
|
298
|
|
|
} |
|
299
|
|
|
|