1
|
<?php
|
2
|
/* --------------------------------------------------------------
|
3
|
CSVImportFunctionLibrary.inc.php 2014-07-15 gm
|
4
|
Gambio GmbH
|
5
|
http://www.gambio.de
|
6
|
Copyright (c) 2014 Gambio GmbH
|
7
|
Released under the GNU General Public License (Version 2)
|
8
|
[http://www.gnu.org/licenses/gpl-2.0.html]
|
9
|
--------------------------------------------------------------
|
10
|
*/
|
11
|
|
12
|
class CSVImportFunctionLibrary extends BaseClass
|
13
|
{
|
14
|
protected $v_import_mapping_array = array();
|
15
|
protected $v_import_data_array = array();
|
16
|
protected $v_headline_array = array();
|
17
|
protected $v_language_array = array();
|
18
|
protected $v_google_export_availability_array = array();
|
19
|
protected $v_csv_source;
|
20
|
protected $v_properties;
|
21
|
protected $v_additional_fields;
|
22
|
protected $v_properties_by_name_array = array();
|
23
|
protected $v_property_values_by_name_array = array();
|
24
|
|
25
|
public function CSVImportFunctionLibrary(&$p_headline_array)
|
26
|
{
|
27
|
$this->set_headline_array($p_headline_array);
|
28
|
$this->init_import();
|
29
|
}
|
30
|
|
31
|
public function clean_data_array()
|
32
|
{
|
33
|
$this->v_import_data_array = array();
|
34
|
}
|
35
|
|
36
|
protected function set_headline_array(&$p_headline_array)
|
37
|
{
|
38
|
$this->v_headline_array = $p_headline_array;
|
39
|
}
|
40
|
|
41
|
public function get_field_name($p_index)
|
42
|
{
|
43
|
$t_field_name = '';
|
44
|
|
45
|
if(isset($this->v_headline_array[$p_index]))
|
46
|
{
|
47
|
$t_field_name = $this->v_headline_array[$p_index];
|
48
|
}
|
49
|
|
50
|
return $t_field_name;
|
51
|
}
|
52
|
|
53
|
public function get_import_data_array()
|
54
|
{
|
55
|
return $this->v_import_data_array;
|
56
|
}
|
57
|
|
58
|
public function init_import()
|
59
|
{
|
60
|
$this->build_language_array();
|
61
|
$this->build_import_mapping_array();
|
62
|
}
|
63
|
|
64
|
protected function build_language_array()
|
65
|
{
|
66
|
$t_sql = '
|
67
|
SELECT languages_id, code
|
68
|
FROM languages';
|
69
|
$t_result = xtc_db_query($t_sql);
|
70
|
|
71
|
while ($t_row = xtc_db_fetch_array($t_result))
|
72
|
{
|
73
|
$this->v_language_array[$t_row['code']] = $t_row['languages_id'];
|
74
|
}
|
75
|
$this->v_language_array[''] = 0;
|
76
|
}
|
77
|
|
78
|
public function get_language_array()
|
79
|
{
|
80
|
return $this->v_language_array;
|
81
|
}
|
82
|
|
83
|
public function get_categories_array()
|
84
|
{
|
85
|
return $this->v_import_data_array['categories'];
|
86
|
}
|
87
|
|
88
|
protected function build_google_export_availability_array()
|
89
|
{
|
90
|
$t_sql = '
|
91
|
SELECT *
|
92
|
FROM google_export_availability';
|
93
|
$t_result = xtc_db_query($t_sql);
|
94
|
|
95
|
while ($t_row = xtc_db_fetch_array($t_result))
|
96
|
{
|
97
|
$this->v_google_export_availability_array[$t_row['availability']] = $t_row['google_export_availability_id'];
|
98
|
}
|
99
|
}
|
100
|
|
101
|
protected function build_import_mapping_array()
|
102
|
{
|
103
|
$this->v_import_mapping_array['p_id'] = array();
|
104
|
$this->v_import_mapping_array['p_id']['table'] = 'products';
|
105
|
$this->v_import_mapping_array['p_id']['column'] = 'products_id';
|
106
|
$this->v_import_mapping_array['p_id']['function'] = '';
|
107
|
|
108
|
$this->v_import_mapping_array['p_model'] = array();
|
109
|
$this->v_import_mapping_array['p_model']['table'] = 'products';
|
110
|
$this->v_import_mapping_array['p_model']['column'] = 'products_model';
|
111
|
$this->v_import_mapping_array['p_model']['function'] = 'products_id_by_model';
|
112
|
|
113
|
$this->v_import_mapping_array['p_stock'] = array();
|
114
|
$this->v_import_mapping_array['p_stock']['table'] = 'products';
|
115
|
$this->v_import_mapping_array['p_stock']['column'] = 'products_quantity';
|
116
|
$this->v_import_mapping_array['p_stock']['function'] = '';
|
117
|
|
118
|
$this->v_import_mapping_array['p_sorting'] = array();
|
119
|
$this->v_import_mapping_array['p_sorting']['table'] = 'products';
|
120
|
$this->v_import_mapping_array['p_sorting']['column'] = 'products_sort';
|
121
|
$this->v_import_mapping_array['p_sorting']['function'] = '';
|
122
|
|
123
|
$this->v_import_mapping_array['p_startpage'] = array();
|
124
|
$this->v_import_mapping_array['p_startpage']['table'] = 'products';
|
125
|
$this->v_import_mapping_array['p_startpage']['column'] = 'products_startpage';
|
126
|
$this->v_import_mapping_array['p_startpage']['function'] = '';
|
127
|
|
128
|
$this->v_import_mapping_array['p_startpage_sort'] = array();
|
129
|
$this->v_import_mapping_array['p_startpage_sort']['table'] = 'products';
|
130
|
$this->v_import_mapping_array['p_startpage_sort']['column'] = 'products_startpage_sort';
|
131
|
$this->v_import_mapping_array['p_startpage_sort']['function'] = '';
|
132
|
|
133
|
$this->v_import_mapping_array['p_shipping'] = array();
|
134
|
$this->v_import_mapping_array['p_shipping']['table'] = 'products';
|
135
|
$this->v_import_mapping_array['p_shipping']['column'] = 'products_shippingtime';
|
136
|
$this->v_import_mapping_array['p_shipping']['function'] = '';
|
137
|
|
138
|
$this->v_import_mapping_array['p_tpl'] = array();
|
139
|
$this->v_import_mapping_array['p_tpl']['table'] = 'products';
|
140
|
$this->v_import_mapping_array['p_tpl']['column'] = 'product_template';
|
141
|
$this->v_import_mapping_array['p_tpl']['function'] = '';
|
142
|
|
143
|
$this->v_import_mapping_array['p_opttpl'] = array();
|
144
|
$this->v_import_mapping_array['p_opttpl']['table'] = 'products';
|
145
|
$this->v_import_mapping_array['p_opttpl']['column'] = 'options_template';
|
146
|
$this->v_import_mapping_array['p_opttpl']['function'] = '';
|
147
|
|
148
|
$this->v_import_mapping_array['p_manufacturer'] = array();
|
149
|
$this->v_import_mapping_array['p_manufacturer']['table'] = 'products';
|
150
|
$this->v_import_mapping_array['p_manufacturer']['column'] = 'manufacturers_id';
|
151
|
$this->v_import_mapping_array['p_manufacturer']['function'] = '';
|
152
|
|
153
|
$this->v_import_mapping_array['p_fsk18'] = array();
|
154
|
$this->v_import_mapping_array['p_fsk18']['table'] = 'products';
|
155
|
$this->v_import_mapping_array['p_fsk18']['column'] = 'products_fsk18';
|
156
|
$this->v_import_mapping_array['p_fsk18']['function'] = '';
|
157
|
|
158
|
$this->v_import_mapping_array['p_priceNoTax'] = array();
|
159
|
$this->v_import_mapping_array['p_priceNoTax']['table'] = 'products';
|
160
|
$this->v_import_mapping_array['p_priceNoTax']['column'] = 'products_price';
|
161
|
$this->v_import_mapping_array['p_priceNoTax']['function'] = 'personal_offer';
|
162
|
|
163
|
$this->v_import_mapping_array['quantity'] = array();
|
164
|
$this->v_import_mapping_array['quantity']['table'] = 'personal_offers_by_customer_status_';
|
165
|
$this->v_import_mapping_array['quantity']['column'] = 'quantity';
|
166
|
$this->v_import_mapping_array['quantity']['function'] = '';
|
167
|
|
168
|
$this->v_import_mapping_array['p_tax'] = array();
|
169
|
$this->v_import_mapping_array['p_tax']['table'] = 'products';
|
170
|
$this->v_import_mapping_array['p_tax']['column'] = 'products_tax_class_id';
|
171
|
$this->v_import_mapping_array['p_tax']['function'] = '';
|
172
|
|
173
|
$this->v_import_mapping_array['p_status'] = array();
|
174
|
$this->v_import_mapping_array['p_status']['table'] = 'products';
|
175
|
$this->v_import_mapping_array['p_status']['column'] = 'products_status';
|
176
|
$this->v_import_mapping_array['p_status']['function'] = '';
|
177
|
|
178
|
$this->v_import_mapping_array['p_weight'] = array();
|
179
|
$this->v_import_mapping_array['p_weight']['table'] = 'products';
|
180
|
$this->v_import_mapping_array['p_weight']['column'] = 'products_weight';
|
181
|
$this->v_import_mapping_array['p_weight']['function'] = '';
|
182
|
|
183
|
$this->v_import_mapping_array['p_ean'] = array();
|
184
|
$this->v_import_mapping_array['p_ean']['table'] = 'products';
|
185
|
$this->v_import_mapping_array['p_ean']['column'] = 'products_ean';
|
186
|
$this->v_import_mapping_array['p_ean']['function'] = '';
|
187
|
|
188
|
$this->v_import_mapping_array['p_type'] = array();
|
189
|
$this->v_import_mapping_array['p_type']['table'] = 'products';
|
190
|
$this->v_import_mapping_array['p_type']['column'] = 'product_type';
|
191
|
$this->v_import_mapping_array['p_type']['function'] = '';
|
192
|
|
193
|
$this->v_import_mapping_array['code_isbn'] = array();
|
194
|
$this->v_import_mapping_array['code_isbn']['table'] = 'products_item_codes';
|
195
|
$this->v_import_mapping_array['code_isbn']['column'] = 'code_isbn';
|
196
|
$this->v_import_mapping_array['code_isbn']['function'] = '';
|
197
|
|
198
|
$this->v_import_mapping_array['code_upc'] = array();
|
199
|
$this->v_import_mapping_array['code_upc']['table'] = 'products_item_codes';
|
200
|
$this->v_import_mapping_array['code_upc']['column'] = 'code_upc';
|
201
|
$this->v_import_mapping_array['code_upc']['function'] = '';
|
202
|
|
203
|
$this->v_import_mapping_array['code_mpn'] = array();
|
204
|
$this->v_import_mapping_array['code_mpn']['table'] = 'products_item_codes';
|
205
|
$this->v_import_mapping_array['code_mpn']['column'] = 'code_mpn';
|
206
|
$this->v_import_mapping_array['code_mpn']['function'] = '';
|
207
|
|
208
|
$this->v_import_mapping_array['code_jan'] = array();
|
209
|
$this->v_import_mapping_array['code_jan']['table'] = 'products_item_codes';
|
210
|
$this->v_import_mapping_array['code_jan']['column'] = 'code_jan';
|
211
|
$this->v_import_mapping_array['code_jan']['function'] = '';
|
212
|
|
213
|
$this->v_import_mapping_array['brand_name'] = array();
|
214
|
$this->v_import_mapping_array['brand_name']['table'] = 'products_item_codes';
|
215
|
$this->v_import_mapping_array['brand_name']['column'] = 'brand_name';
|
216
|
$this->v_import_mapping_array['brand_name']['function'] = '';
|
217
|
|
218
|
$this->v_import_mapping_array['p_disc'] = array();
|
219
|
$this->v_import_mapping_array['p_disc']['table'] = 'products';
|
220
|
$this->v_import_mapping_array['p_disc']['column'] = 'products_discount_allowed';
|
221
|
$this->v_import_mapping_array['p_disc']['function'] = '';
|
222
|
|
223
|
$this->v_import_mapping_array['p_date_added'] = array();
|
224
|
$this->v_import_mapping_array['p_date_added']['table'] = 'products';
|
225
|
$this->v_import_mapping_array['p_date_added']['column'] = 'products_date_added';
|
226
|
$this->v_import_mapping_array['p_date_added']['function'] = '';
|
227
|
|
228
|
$this->v_import_mapping_array['p_last_modified'] = array();
|
229
|
$this->v_import_mapping_array['p_last_modified']['table'] = 'products';
|
230
|
$this->v_import_mapping_array['p_last_modified']['column'] = 'products_last_modified';
|
231
|
$this->v_import_mapping_array['p_last_modified']['function'] = '';
|
232
|
|
233
|
$this->v_import_mapping_array['p_date_available'] = array();
|
234
|
$this->v_import_mapping_array['p_date_available']['table'] = 'products';
|
235
|
$this->v_import_mapping_array['p_date_available']['column'] = 'products_date_available';
|
236
|
$this->v_import_mapping_array['p_date_available']['function'] = '';
|
237
|
|
238
|
$this->v_import_mapping_array['p_ordered'] = array();
|
239
|
$this->v_import_mapping_array['p_ordered']['table'] = 'products';
|
240
|
$this->v_import_mapping_array['p_ordered']['column'] = 'products_ordered';
|
241
|
$this->v_import_mapping_array['p_ordered']['function'] = '';
|
242
|
|
243
|
$this->v_import_mapping_array['nc_ultra_shipping_costs'] = array();
|
244
|
$this->v_import_mapping_array['nc_ultra_shipping_costs']['table'] = 'products';
|
245
|
$this->v_import_mapping_array['nc_ultra_shipping_costs']['column'] = 'nc_ultra_shipping_costs';
|
246
|
$this->v_import_mapping_array['nc_ultra_shipping_costs']['function'] = '';
|
247
|
|
248
|
$this->v_import_mapping_array['gm_show_date_added'] = array();
|
249
|
$this->v_import_mapping_array['gm_show_date_added']['table'] = 'products';
|
250
|
$this->v_import_mapping_array['gm_show_date_added']['column'] = 'gm_show_date_added';
|
251
|
$this->v_import_mapping_array['gm_show_date_added']['function'] = '';
|
252
|
|
253
|
$this->v_import_mapping_array['gm_show_price_offer'] = array();
|
254
|
$this->v_import_mapping_array['gm_show_price_offer']['table'] = 'products';
|
255
|
$this->v_import_mapping_array['gm_show_price_offer']['column'] = 'gm_show_price_offer';
|
256
|
$this->v_import_mapping_array['gm_show_price_offer']['function'] = '';
|
257
|
|
258
|
$this->v_import_mapping_array['gm_show_weight'] = array();
|
259
|
$this->v_import_mapping_array['gm_show_weight']['table'] = 'products';
|
260
|
$this->v_import_mapping_array['gm_show_weight']['column'] = 'gm_show_weight';
|
261
|
$this->v_import_mapping_array['gm_show_weight']['function'] = '';
|
262
|
|
263
|
$this->v_import_mapping_array['gm_show_qty_info'] = array();
|
264
|
$this->v_import_mapping_array['gm_show_qty_info']['table'] = 'products';
|
265
|
$this->v_import_mapping_array['gm_show_qty_info']['column'] = 'gm_show_qty_info';
|
266
|
$this->v_import_mapping_array['gm_show_qty_info']['function'] = '';
|
267
|
|
268
|
$this->v_import_mapping_array['gm_price_status'] = array();
|
269
|
$this->v_import_mapping_array['gm_price_status']['table'] = 'products';
|
270
|
$this->v_import_mapping_array['gm_price_status']['column'] = 'gm_price_status';
|
271
|
$this->v_import_mapping_array['gm_price_status']['function'] = '';
|
272
|
|
273
|
$this->v_import_mapping_array['gm_min_order'] = array();
|
274
|
$this->v_import_mapping_array['gm_min_order']['table'] = 'products';
|
275
|
$this->v_import_mapping_array['gm_min_order']['column'] = 'gm_min_order';
|
276
|
$this->v_import_mapping_array['gm_min_order']['function'] = '';
|
277
|
|
278
|
$this->v_import_mapping_array['gm_graduated_qty'] = array();
|
279
|
$this->v_import_mapping_array['gm_graduated_qty']['table'] = 'products';
|
280
|
$this->v_import_mapping_array['gm_graduated_qty']['column'] = 'gm_graduated_qty';
|
281
|
$this->v_import_mapping_array['gm_graduated_qty']['function'] = '';
|
282
|
|
283
|
$this->v_import_mapping_array['gm_options_template'] = array();
|
284
|
$this->v_import_mapping_array['gm_options_template']['table'] = 'products';
|
285
|
$this->v_import_mapping_array['gm_options_template']['column'] = 'gm_options_template';
|
286
|
$this->v_import_mapping_array['gm_options_template']['function'] = '';
|
287
|
|
288
|
$this->v_import_mapping_array['p_vpe'] = array();
|
289
|
$this->v_import_mapping_array['p_vpe']['table'] = 'products';
|
290
|
$this->v_import_mapping_array['p_vpe']['column'] = 'products_vpe';
|
291
|
$this->v_import_mapping_array['p_vpe']['function'] = '';
|
292
|
|
293
|
$this->v_import_mapping_array['p_vpe_status'] = array();
|
294
|
$this->v_import_mapping_array['p_vpe_status']['table'] = 'products';
|
295
|
$this->v_import_mapping_array['p_vpe_status']['column'] = 'products_vpe_status';
|
296
|
$this->v_import_mapping_array['p_vpe_status']['function'] = '';
|
297
|
|
298
|
$this->v_import_mapping_array['p_vpe_value'] = array();
|
299
|
$this->v_import_mapping_array['p_vpe_value']['table'] = 'products';
|
300
|
$this->v_import_mapping_array['p_vpe_value']['column'] = 'products_vpe_value';
|
301
|
$this->v_import_mapping_array['p_vpe_value']['function'] = '';
|
302
|
|
303
|
$this->v_import_mapping_array['p_image'] = array();
|
304
|
$this->v_import_mapping_array['p_image']['table'] = 'products';
|
305
|
$this->v_import_mapping_array['p_image']['column'] = 'products_image';
|
306
|
$this->v_import_mapping_array['p_image']['function'] = 'additional_image';
|
307
|
|
308
|
$this->v_import_mapping_array['image_nr'] = array();
|
309
|
$this->v_import_mapping_array['image_nr']['table'] = 'products_images';
|
310
|
$this->v_import_mapping_array['image_nr']['column'] = 'image_nr';
|
311
|
$this->v_import_mapping_array['image_nr']['function'] = '';
|
312
|
|
313
|
$this->v_import_mapping_array['p_name'] = array();
|
314
|
$this->v_import_mapping_array['p_name']['table'] = 'products_description';
|
315
|
$this->v_import_mapping_array['p_name']['column'] = 'products_name';
|
316
|
$this->v_import_mapping_array['p_name']['function'] = 'by_language';
|
317
|
|
318
|
$this->v_import_mapping_array['p_desc'] = array();
|
319
|
$this->v_import_mapping_array['p_desc']['table'] = 'products_description';
|
320
|
$this->v_import_mapping_array['p_desc']['column'] = 'products_description';
|
321
|
$this->v_import_mapping_array['p_desc']['function'] = 'by_language';
|
322
|
|
323
|
$this->v_import_mapping_array['p_shortdesc'] = array();
|
324
|
$this->v_import_mapping_array['p_shortdesc']['table'] = 'products_description';
|
325
|
$this->v_import_mapping_array['p_shortdesc']['column'] = 'products_short_description';
|
326
|
$this->v_import_mapping_array['p_shortdesc']['function'] = 'by_language';
|
327
|
|
328
|
$this->v_import_mapping_array['p_meta_title'] = array();
|
329
|
$this->v_import_mapping_array['p_meta_title']['table'] = 'products_description';
|
330
|
$this->v_import_mapping_array['p_meta_title']['column'] = 'products_meta_title';
|
331
|
$this->v_import_mapping_array['p_meta_title']['function'] = 'by_language';
|
332
|
|
333
|
$this->v_import_mapping_array['p_meta_desc'] = array();
|
334
|
$this->v_import_mapping_array['p_meta_desc']['table'] = 'products_description';
|
335
|
$this->v_import_mapping_array['p_meta_desc']['column'] = 'products_meta_description';
|
336
|
$this->v_import_mapping_array['p_meta_desc']['function'] = 'by_language';
|
337
|
|
338
|
$this->v_import_mapping_array['p_meta_key'] = array();
|
339
|
$this->v_import_mapping_array['p_meta_key']['table'] = 'products_description';
|
340
|
$this->v_import_mapping_array['p_meta_key']['column'] = 'products_meta_keywords';
|
341
|
$this->v_import_mapping_array['p_meta_key']['function'] = 'by_language';
|
342
|
|
343
|
$this->v_import_mapping_array['p_keywords'] = array();
|
344
|
$this->v_import_mapping_array['p_keywords']['table'] = 'products_description';
|
345
|
$this->v_import_mapping_array['p_keywords']['column'] = 'products_keywords';
|
346
|
$this->v_import_mapping_array['p_keywords']['function'] = 'by_language';
|
347
|
|
348
|
$this->v_import_mapping_array['p_url'] = array();
|
349
|
$this->v_import_mapping_array['p_url']['table'] = 'products_description';
|
350
|
$this->v_import_mapping_array['p_url']['column'] = 'products_url';
|
351
|
$this->v_import_mapping_array['p_url']['function'] = 'by_language';
|
352
|
|
353
|
$this->v_import_mapping_array['gm_url_keywords'] = array();
|
354
|
$this->v_import_mapping_array['gm_url_keywords']['table'] = 'products_description';
|
355
|
$this->v_import_mapping_array['gm_url_keywords']['column'] = 'gm_url_keywords';
|
356
|
$this->v_import_mapping_array['gm_url_keywords']['function'] = 'by_language';
|
357
|
|
358
|
$this->v_import_mapping_array['p_checkout_information'] = array();
|
359
|
$this->v_import_mapping_array['p_checkout_information']['table'] = 'products_description';
|
360
|
$this->v_import_mapping_array['p_checkout_information']['column'] = 'checkout_information';
|
361
|
$this->v_import_mapping_array['p_checkout_information']['function'] = 'by_language';
|
362
|
|
363
|
$this->v_import_mapping_array['p_cat'] = array();
|
364
|
$this->v_import_mapping_array['p_cat']['table'] = 'products_to_categories';
|
365
|
$this->v_import_mapping_array['p_cat']['column'] = 'categories_id';
|
366
|
$this->v_import_mapping_array['p_cat']['function'] = 'resolve_c_path';
|
367
|
|
368
|
$this->v_import_mapping_array['google_export_availability'] = array();
|
369
|
$this->v_import_mapping_array['google_export_availability']['table'] = 'products_item_codes';
|
370
|
$this->v_import_mapping_array['google_export_availability']['column'] = 'google_export_availability_id';
|
371
|
$this->v_import_mapping_array['google_export_availability']['function'] = 'convert_google_export_availability';
|
372
|
|
373
|
$this->v_import_mapping_array['google_export_condition'] = array();
|
374
|
$this->v_import_mapping_array['google_export_condition']['table'] = 'products_item_codes';
|
375
|
$this->v_import_mapping_array['google_export_condition']['column'] = 'google_export_condition';
|
376
|
$this->v_import_mapping_array['google_export_condition']['function'] = '';
|
377
|
|
378
|
$this->v_import_mapping_array['google_category'] = array();
|
379
|
$this->v_import_mapping_array['google_category']['table'] = 'products_google_categories';
|
380
|
$this->v_import_mapping_array['google_category']['column'] = 'google_category';
|
381
|
$this->v_import_mapping_array['google_category']['function'] = '';
|
382
|
|
383
|
$this->v_import_mapping_array['p_img_alt_text'] = array();
|
384
|
$this->v_import_mapping_array['p_img_alt_text']['table'] = 'products_description';
|
385
|
$this->v_import_mapping_array['p_img_alt_text']['column'] = 'gm_alt_text';
|
386
|
$this->v_import_mapping_array['p_img_alt_text']['function'] = 'by_language,additional_image_alt_text';
|
387
|
|
388
|
$this->v_import_mapping_array['p_group_permission'] = array();
|
389
|
$this->v_import_mapping_array['p_group_permission']['table'] = 'products';
|
390
|
$this->v_import_mapping_array['p_group_permission']['column'] = 'group_permission_0';
|
391
|
$this->v_import_mapping_array['p_group_permission']['function'] = 'group_permission';
|
392
|
|
393
|
$this->v_import_mapping_array['specials_qty'] = array();
|
394
|
$this->v_import_mapping_array['specials_qty']['table'] = 'specials';
|
395
|
$this->v_import_mapping_array['specials_qty']['column'] = 'specials_quantity';
|
396
|
$this->v_import_mapping_array['specials_qty']['function'] = '';
|
397
|
|
398
|
$this->v_import_mapping_array['specials_new_products_price'] = array();
|
399
|
$this->v_import_mapping_array['specials_new_products_price']['table'] = 'specials';
|
400
|
$this->v_import_mapping_array['specials_new_products_price']['column'] = 'specials_new_products_price';
|
401
|
$this->v_import_mapping_array['specials_new_products_price']['function'] = '';
|
402
|
|
403
|
$this->v_import_mapping_array['expires_date'] = array();
|
404
|
$this->v_import_mapping_array['expires_date']['table'] = 'specials';
|
405
|
$this->v_import_mapping_array['expires_date']['column'] = 'expires_date';
|
406
|
$this->v_import_mapping_array['expires_date']['function'] = '';
|
407
|
|
408
|
$this->v_import_mapping_array['specials_status'] = array();
|
409
|
$this->v_import_mapping_array['specials_status']['table'] = 'specials';
|
410
|
$this->v_import_mapping_array['specials_status']['column'] = 'status';
|
411
|
$this->v_import_mapping_array['specials_status']['function'] = '';
|
412
|
|
413
|
$this->v_import_mapping_array['gm_priority'] = array();
|
414
|
$this->v_import_mapping_array['gm_priority']['table'] = 'products';
|
415
|
$this->v_import_mapping_array['gm_priority']['column'] = 'gm_priority';
|
416
|
$this->v_import_mapping_array['gm_priority']['function'] = '';
|
417
|
|
418
|
$this->v_import_mapping_array['gm_changefreq'] = array();
|
419
|
$this->v_import_mapping_array['gm_changefreq']['table'] = 'products';
|
420
|
$this->v_import_mapping_array['gm_changefreq']['column'] = 'gm_changefreq';
|
421
|
$this->v_import_mapping_array['gm_changefreq']['function'] = '';
|
422
|
|
423
|
$this->v_import_mapping_array['gm_sitemap_entry'] = array();
|
424
|
$this->v_import_mapping_array['gm_sitemap_entry']['table'] = 'products';
|
425
|
$this->v_import_mapping_array['gm_sitemap_entry']['column'] = 'gm_sitemap_entry';
|
426
|
$this->v_import_mapping_array['gm_sitemap_entry']['function'] = '';
|
427
|
|
428
|
$this->v_import_mapping_array['p_qty_unit_id'] = array();
|
429
|
$this->v_import_mapping_array['p_qty_unit_id']['table'] = 'products_quantity_unit';
|
430
|
$this->v_import_mapping_array['p_qty_unit_id']['column'] = 'quantity_unit_id';
|
431
|
$this->v_import_mapping_array['p_qty_unit_id']['function'] = '';
|
432
|
|
433
|
$this->v_import_mapping_array['categories_id'] = array();
|
434
|
$this->v_import_mapping_array['categories_id']['table'] = 'categories';
|
435
|
$this->v_import_mapping_array['categories_id']['column'] = 'categories_id';
|
436
|
$this->v_import_mapping_array['categories_id']['function'] = 'additional_level';
|
437
|
|
438
|
$this->v_import_mapping_array['parent_id'] = array();
|
439
|
$this->v_import_mapping_array['parent_id']['table'] = 'categories';
|
440
|
$this->v_import_mapping_array['parent_id']['column'] = 'parent_id';
|
441
|
$this->v_import_mapping_array['parent_id']['function'] = 'additional_level';
|
442
|
|
443
|
$this->v_import_mapping_array['categories_status'] = array();
|
444
|
$this->v_import_mapping_array['categories_status']['table'] = 'categories';
|
445
|
$this->v_import_mapping_array['categories_status']['column'] = 'categories_status';
|
446
|
$this->v_import_mapping_array['categories_status']['function'] = 'additional_level';
|
447
|
|
448
|
$this->v_import_mapping_array['date_added'] = array();
|
449
|
$this->v_import_mapping_array['date_added']['table'] = 'categories';
|
450
|
$this->v_import_mapping_array['date_added']['column'] = 'date_added';
|
451
|
$this->v_import_mapping_array['date_added']['function'] = 'additional_level';
|
452
|
|
453
|
$this->v_import_mapping_array['last_modified'] = array();
|
454
|
$this->v_import_mapping_array['last_modified']['table'] = 'categories';
|
455
|
$this->v_import_mapping_array['last_modified']['column'] = 'last_modified';
|
456
|
$this->v_import_mapping_array['last_modified']['function'] = 'additional_level';
|
457
|
|
458
|
$this->v_import_mapping_array['categories_name'] = array();
|
459
|
$this->v_import_mapping_array['categories_name']['table'] = 'categories_description';
|
460
|
$this->v_import_mapping_array['categories_name']['column'] = 'categories_name';
|
461
|
$this->v_import_mapping_array['categories_name']['function'] = 'by_language,additional_level';
|
462
|
|
463
|
$this->v_import_mapping_array['categories_description_id'] = array();
|
464
|
$this->v_import_mapping_array['categories_description_id']['table'] = 'categories_description';
|
465
|
$this->v_import_mapping_array['categories_description_id']['column'] = 'categories_id';
|
466
|
$this->v_import_mapping_array['categories_description_id']['function'] = 'by_language,additional_level';
|
467
|
|
468
|
$this->v_import_mapping_array['products_properties_combis_id'] = array();
|
469
|
$this->v_import_mapping_array['products_properties_combis_id']['table'] = 'products_properties_combis';
|
470
|
$this->v_import_mapping_array['products_properties_combis_id']['column'] = 'products_properties_combis_id';
|
471
|
$this->v_import_mapping_array['products_properties_combis_id']['function'] = '';
|
472
|
|
473
|
$this->v_import_mapping_array['combi_sort_order'] = array();
|
474
|
$this->v_import_mapping_array['combi_sort_order']['table'] = 'products_properties_combis';
|
475
|
$this->v_import_mapping_array['combi_sort_order']['column'] = 'sort_order';
|
476
|
$this->v_import_mapping_array['combi_sort_order']['function'] = '';
|
477
|
|
478
|
$this->v_import_mapping_array['combi_model'] = array();
|
479
|
$this->v_import_mapping_array['combi_model']['table'] = 'products_properties_combis';
|
480
|
$this->v_import_mapping_array['combi_model']['column'] = 'combi_model';
|
481
|
$this->v_import_mapping_array['combi_model']['function'] = '';
|
482
|
|
483
|
$this->v_import_mapping_array['combi_ean'] = array();
|
484
|
$this->v_import_mapping_array['combi_ean']['table'] = 'products_properties_combis';
|
485
|
$this->v_import_mapping_array['combi_ean']['column'] = 'combi_ean';
|
486
|
$this->v_import_mapping_array['combi_ean']['function'] = '';
|
487
|
|
488
|
$this->v_import_mapping_array['combi_quantity'] = array();
|
489
|
$this->v_import_mapping_array['combi_quantity']['table'] = 'products_properties_combis';
|
490
|
$this->v_import_mapping_array['combi_quantity']['column'] = 'combi_quantity';
|
491
|
$this->v_import_mapping_array['combi_quantity']['function'] = '';
|
492
|
|
493
|
$this->v_import_mapping_array['combi_shipping_status_id'] = array();
|
494
|
$this->v_import_mapping_array['combi_shipping_status_id']['table'] = 'products_properties_combis';
|
495
|
$this->v_import_mapping_array['combi_shipping_status_id']['column'] = 'combi_shipping_status_id';
|
496
|
$this->v_import_mapping_array['combi_shipping_status_id']['function'] = '';
|
497
|
|
498
|
$this->v_import_mapping_array['combi_weight'] = array();
|
499
|
$this->v_import_mapping_array['combi_weight']['table'] = 'products_properties_combis';
|
500
|
$this->v_import_mapping_array['combi_weight']['column'] = 'combi_weight';
|
501
|
$this->v_import_mapping_array['combi_weight']['function'] = '';
|
502
|
|
503
|
$this->v_import_mapping_array['combi_price_type'] = array();
|
504
|
$this->v_import_mapping_array['combi_price_type']['table'] = 'products_properties_combis';
|
505
|
$this->v_import_mapping_array['combi_price_type']['column'] = 'combi_price_type';
|
506
|
$this->v_import_mapping_array['combi_price_type']['function'] = '';
|
507
|
|
508
|
$this->v_import_mapping_array['combi_price'] = array();
|
509
|
$this->v_import_mapping_array['combi_price']['table'] = 'products_properties_combis';
|
510
|
$this->v_import_mapping_array['combi_price']['column'] = 'combi_price';
|
511
|
$this->v_import_mapping_array['combi_price']['function'] = '';
|
512
|
|
513
|
$this->v_import_mapping_array['combi_image'] = array();
|
514
|
$this->v_import_mapping_array['combi_image']['table'] = 'products_properties_combis';
|
515
|
$this->v_import_mapping_array['combi_image']['column'] = 'combi_image';
|
516
|
$this->v_import_mapping_array['combi_image']['function'] = '';
|
517
|
|
518
|
$this->v_import_mapping_array['combi_vpe_id'] = array();
|
519
|
$this->v_import_mapping_array['combi_vpe_id']['table'] = 'products_properties_combis';
|
520
|
$this->v_import_mapping_array['combi_vpe_id']['column'] = 'products_vpe_id';
|
521
|
$this->v_import_mapping_array['combi_vpe_id']['function'] = '';
|
522
|
|
523
|
$this->v_import_mapping_array['combi_vpe_value'] = array();
|
524
|
$this->v_import_mapping_array['combi_vpe_value']['table'] = 'products_properties_combis';
|
525
|
$this->v_import_mapping_array['combi_vpe_value']['column'] = 'vpe_value';
|
526
|
$this->v_import_mapping_array['combi_vpe_value']['function'] = '';
|
527
|
|
528
|
$this->v_import_mapping_array['property'] = array();
|
529
|
$this->v_import_mapping_array['property']['table'] = '';
|
530
|
$this->v_import_mapping_array['property']['column'] = '';
|
531
|
$this->v_import_mapping_array['property']['function'] = 'property';
|
532
|
|
533
|
$this->v_import_mapping_array['properties_values-properties_values_id'] = array();
|
534
|
$this->v_import_mapping_array['properties_values-properties_values_id']['table'] = 'properties_values';
|
535
|
$this->v_import_mapping_array['properties_values-properties_values_id']['column'] = 'properties_values_id';
|
536
|
$this->v_import_mapping_array['properties_values-properties_values_id']['function'] = 'by_property';
|
537
|
|
538
|
$this->v_import_mapping_array['properties_values-properties_id'] = array();
|
539
|
$this->v_import_mapping_array['properties_values-properties_id']['table'] = 'properties_values';
|
540
|
$this->v_import_mapping_array['properties_values-properties_id']['column'] = 'properties_id';
|
541
|
$this->v_import_mapping_array['properties_values-properties_id']['function'] = 'by_property';
|
542
|
|
543
|
$this->v_import_mapping_array['properties_values_description-properties_values_id'] = array();
|
544
|
$this->v_import_mapping_array['properties_values_description-properties_values_id']['table'] = 'properties_values_description';
|
545
|
$this->v_import_mapping_array['properties_values_description-properties_values_id']['column'] = 'properties_values_id';
|
546
|
$this->v_import_mapping_array['properties_values_description-properties_values_id']['function'] = 'by_property';
|
547
|
|
548
|
$this->v_import_mapping_array['properties_values_description-language_id'] = array();
|
549
|
$this->v_import_mapping_array['properties_values_description-language_id']['table'] = 'properties_values_description';
|
550
|
$this->v_import_mapping_array['properties_values_description-language_id']['column'] = 'language_id';
|
551
|
$this->v_import_mapping_array['properties_values_description-language_id']['function'] = 'by_property';
|
552
|
|
553
|
$this->v_import_mapping_array['properties_values_description-values_name'] = array();
|
554
|
$this->v_import_mapping_array['properties_values_description-values_name']['table'] = 'properties_values_description';
|
555
|
$this->v_import_mapping_array['properties_values_description-values_name']['column'] = 'values_name';
|
556
|
$this->v_import_mapping_array['properties_values_description-values_name']['function'] = 'by_property';
|
557
|
|
558
|
$this->v_import_mapping_array['products_properties_combis_values-properties_values_id'] = array();
|
559
|
$this->v_import_mapping_array['products_properties_combis_values-properties_values_id']['table'] = 'products_properties_combis_values';
|
560
|
$this->v_import_mapping_array['products_properties_combis_values-properties_values_id']['column'] = 'properties_values_id';
|
561
|
$this->v_import_mapping_array['products_properties_combis_values-properties_values_id']['function'] = 'by_property';
|
562
|
|
563
|
$this->v_import_mapping_array['products_properties_admin_select-properties_id'] = array();
|
564
|
$this->v_import_mapping_array['products_properties_admin_select-properties_id']['table'] = 'products_properties_admin_select';
|
565
|
$this->v_import_mapping_array['products_properties_admin_select-properties_id']['column'] = 'properties_id';
|
566
|
$this->v_import_mapping_array['products_properties_admin_select-properties_id']['function'] = 'by_property';
|
567
|
|
568
|
$this->v_import_mapping_array['products_properties_admin_select-properties_values_id'] = array();
|
569
|
$this->v_import_mapping_array['products_properties_admin_select-properties_values_id']['table'] = 'products_properties_admin_select';
|
570
|
$this->v_import_mapping_array['products_properties_admin_select-properties_values_id']['column'] = 'properties_values_id';
|
571
|
$this->v_import_mapping_array['products_properties_admin_select-properties_values_id']['function'] = 'by_property';
|
572
|
|
573
|
$this->v_import_mapping_array['additional_field'] = array();
|
574
|
$this->v_import_mapping_array['additional_field']['table'] = '';
|
575
|
$this->v_import_mapping_array['additional_field']['column'] = '';
|
576
|
$this->v_import_mapping_array['additional_field']['function'] = 'additional_field';
|
577
|
|
578
|
$this->v_import_mapping_array['additional_field_values-additional_field_value_id'] = array();
|
579
|
$this->v_import_mapping_array['additional_field_values-additional_field_value_id']['table'] = 'additional_field_values';
|
580
|
$this->v_import_mapping_array['additional_field_values-additional_field_value_id']['column'] = 'additional_field_value_id';
|
581
|
$this->v_import_mapping_array['additional_field_values-additional_field_value_id']['function'] = 'additional_level';
|
582
|
|
583
|
$this->v_import_mapping_array['additional_field_values-additional_field_id'] = array();
|
584
|
$this->v_import_mapping_array['additional_field_values-additional_field_id']['table'] = 'additional_field_values';
|
585
|
$this->v_import_mapping_array['additional_field_values-additional_field_id']['column'] = 'additional_field_id';
|
586
|
$this->v_import_mapping_array['additional_field_values-additional_field_id']['function'] = 'additional_level';
|
587
|
|
588
|
$this->v_import_mapping_array['additional_field_value_descriptions-additional_field_value_id'] = array();
|
589
|
$this->v_import_mapping_array['additional_field_value_descriptions-additional_field_value_id']['table'] = 'additional_field_value_descriptions';
|
590
|
$this->v_import_mapping_array['additional_field_value_descriptions-additional_field_value_id']['column'] = 'additional_field_value_id';
|
591
|
$this->v_import_mapping_array['additional_field_value_descriptions-additional_field_value_id']['function'] = 'by_language,additional_level';
|
592
|
|
593
|
$this->v_import_mapping_array['additional_field_value_descriptions-language_id'] = array();
|
594
|
$this->v_import_mapping_array['additional_field_value_descriptions-language_id']['table'] = 'additional_field_value_descriptions';
|
595
|
$this->v_import_mapping_array['additional_field_value_descriptions-language_id']['column'] = 'language_id';
|
596
|
$this->v_import_mapping_array['additional_field_value_descriptions-language_id']['function'] = 'by_language,additional_level';
|
597
|
|
598
|
$this->v_import_mapping_array['additional_field_value_descriptions-value'] = array();
|
599
|
$this->v_import_mapping_array['additional_field_value_descriptions-value']['table'] = 'additional_field_value_descriptions';
|
600
|
$this->v_import_mapping_array['additional_field_value_descriptions-value']['column'] = 'value';
|
601
|
$this->v_import_mapping_array['additional_field_value_descriptions-value']['function'] = 'by_language,additional_level';
|
602
|
}
|
603
|
|
604
|
|
605
|
public function set_field_content($p_field_name, $p_field_value)
|
606
|
{
|
607
|
$c_field_name = trim((strpos_wrapper($p_field_name, '.') !== false) ? substr_wrapper($p_field_name, 0, strpos_wrapper($p_field_name, '.')) : $p_field_name);
|
608
|
|
609
|
if (strpos_wrapper($c_field_name, 'Eigenschaft:') === 0)
|
610
|
{
|
611
|
$c_field_name = 'property';
|
612
|
}
|
613
|
|
614
|
if (strpos_wrapper($c_field_name, 'Zusatzfeld:') === 0)
|
615
|
{
|
616
|
$c_field_name = 'additional_field';
|
617
|
}
|
618
|
|
619
|
if (array_key_exists($c_field_name, $this->v_import_mapping_array))
|
620
|
{
|
621
|
$t_field_data = array();
|
622
|
$t_field_data['table'] = $this->v_import_mapping_array[$c_field_name]['table'];
|
623
|
$t_field_data['column'] = $this->v_import_mapping_array[$c_field_name]['column'];
|
624
|
$t_field_data['value'] = $p_field_value;
|
625
|
if ($c_field_name == 'property')
|
626
|
{
|
627
|
$t_field_data['property'] = $p_field_name;
|
628
|
}
|
629
|
if ($c_field_name == 'additional_field')
|
630
|
{
|
631
|
$t_field_data['additional_field'] = $p_field_name;
|
632
|
}
|
633
|
|
634
|
if (!empty($this->v_import_mapping_array[$c_field_name]['function']))
|
635
|
{
|
636
|
$t_functions = explode(',', $this->v_import_mapping_array[$c_field_name]['function']);
|
637
|
$t_clean_field_name = substr_wrapper($p_field_name, 0, strpos_wrapper($p_field_name, '[') !== false ? strpos_wrapper($p_field_name, '[') : strlen_wrapper($p_field_name));
|
638
|
$t_params = explode('.', $t_clean_field_name);
|
639
|
$t_params[0] = &$t_field_data;
|
640
|
|
641
|
foreach ($t_functions as $t_function)
|
642
|
{
|
643
|
eval('$this->' . trim($t_function) . '($t_params);');
|
644
|
}
|
645
|
}
|
646
|
|
647
|
$this->add_import_field($t_field_data);
|
648
|
}
|
649
|
}
|
650
|
|
651
|
protected function add_import_field($p_field_data)
|
652
|
{
|
653
|
if (empty($p_field_data['table']))
|
654
|
{
|
655
|
return;
|
656
|
}
|
657
|
|
658
|
if (!array_key_exists($p_field_data['table'], $this->v_import_data_array))
|
659
|
{
|
660
|
$this->v_import_data_array[$p_field_data['table']] = array();
|
661
|
}
|
662
|
|
663
|
$this->build_field_data_recursively($this->v_import_data_array[$p_field_data['table']], $p_field_data['value'], $p_field_data['column']);
|
664
|
}
|
665
|
|
666
|
protected function build_field_data_recursively(&$p_data_array, $p_field_data, $p_column_name)
|
667
|
{
|
668
|
if (!is_array($p_data_array))
|
669
|
{
|
670
|
$p_data_array = array();
|
671
|
}
|
672
|
|
673
|
if (is_array($p_field_data))
|
674
|
{
|
675
|
foreach ($p_field_data as $t_key => $t_val)
|
676
|
{
|
677
|
$this->build_field_data_recursively($p_data_array[$t_key], $t_val, $p_column_name);
|
678
|
}
|
679
|
}
|
680
|
else
|
681
|
{
|
682
|
$p_data_array[$p_column_name] = trim($p_field_data);
|
683
|
}
|
684
|
}
|
685
|
|
686
|
protected function products_id_by_model(&$p_field_params)
|
687
|
{
|
688
|
if(!empty($this->v_import_data_array['products']['products_id']) || trim($p_field_params[0]['value']) === '')
|
689
|
{
|
690
|
return;
|
691
|
}
|
692
|
|
693
|
$t_sql = "SELECT products_id
|
694
|
FROM " . TABLE_PRODUCTS . "
|
695
|
WHERE products_model = '" . xtc_db_input($p_field_params[0]['value']) . "'
|
696
|
LIMIT 1";
|
697
|
$t_result = xtc_db_query($t_sql);
|
698
|
|
699
|
if(xtc_db_num_rows($t_result) == 1)
|
700
|
{
|
701
|
$t_result_array = xtc_db_fetch_array($t_result);
|
702
|
$this->v_import_data_array['products']['products_id'] = $t_result_array['products_id'];
|
703
|
}
|
704
|
}
|
705
|
|
706
|
protected function by_language(&$p_field_params, $p_param_position = false)
|
707
|
{
|
708
|
if($p_param_position === false)
|
709
|
{
|
710
|
$t_index = count($p_field_params) - 1;
|
711
|
}
|
712
|
else
|
713
|
{
|
714
|
$t_index = $p_param_position;
|
715
|
}
|
716
|
|
717
|
$t_lang_code = '';
|
718
|
if(isset($this->v_language_array[$p_field_params[$t_index]]))
|
719
|
{
|
720
|
$t_lang_code = $p_field_params[$t_index];
|
721
|
}
|
722
|
$t_lang_id = $this->v_language_array[$t_lang_code];
|
723
|
$t_temp = $p_field_params[0]['value'];
|
724
|
$p_field_params[0]['value'] = array();
|
725
|
$p_field_params[0]['value'][$t_lang_id] = $t_temp;
|
726
|
}
|
727
|
|
728
|
protected function by_property(&$p_field_params)
|
729
|
{
|
730
|
$t_temp = $p_field_params[0]['value'];
|
731
|
$p_field_params[0]['value'] = array();
|
732
|
$p_field_params[0]['value'][$p_field_params[1]] = $t_temp;
|
733
|
}
|
734
|
|
735
|
protected function personal_offer(&$p_field_params)
|
736
|
{
|
737
|
if (!isset($p_field_params[1]) || empty($p_field_params[1]))
|
738
|
{
|
739
|
return;
|
740
|
}
|
741
|
$c_customer_group = (int) $p_field_params[1];
|
742
|
$p_field_params[0]['table'] = 'personal_offers_by_customers_status_' . $c_customer_group;
|
743
|
$p_field_params[0]['column'] = 'personal_offer';
|
744
|
$t_offers_array = explode('::', $p_field_params[0]['value']);
|
745
|
$p_field_params[0]['value'] = array();
|
746
|
|
747
|
foreach ($t_offers_array as $t_offer)
|
748
|
{
|
749
|
$t_quantity_offers = explode(':', $t_offer);
|
750
|
if (count($t_quantity_offers) == 1)
|
751
|
{
|
752
|
$t_quantity = '1';
|
753
|
$t_offer_price = $t_offer;
|
754
|
}
|
755
|
else
|
756
|
{
|
757
|
$t_quantity = $t_quantity_offers[0];
|
758
|
$t_offer_price = $t_quantity_offers[1];
|
759
|
}
|
760
|
$p_field_params[0]['value'][$t_quantity] = $t_offer_price;
|
761
|
}
|
762
|
}
|
763
|
|
764
|
protected function group_permission(&$p_field_params)
|
765
|
{
|
766
|
$c_customer_group = (int) $p_field_params[1];
|
767
|
$p_field_params[0]['column'] = 'group_permission_' . $c_customer_group;
|
768
|
}
|
769
|
|
770
|
protected function additional_image(&$p_field_params)
|
771
|
{
|
772
|
if (!isset($p_field_params[1]) || empty($p_field_params[1]))
|
773
|
{
|
774
|
return;
|
775
|
}
|
776
|
|
777
|
$c_image_index = (int) $p_field_params[1];
|
778
|
$p_field_params[0]['table'] = 'products_images';
|
779
|
$p_field_params[0]['column'] = 'image_name';
|
780
|
$t_temp = $p_field_params[0]['value'];
|
781
|
$p_field_params[0]['value'] = array();
|
782
|
$p_field_params[0]['value'][$c_image_index] = $t_temp;
|
783
|
}
|
784
|
|
785
|
protected function additional_image_alt_text(&$p_field_params)
|
786
|
{
|
787
|
if(isset($p_field_params[1]) && !is_numeric($p_field_params[1]))
|
788
|
{
|
789
|
return;
|
790
|
}
|
791
|
elseif (!isset($p_field_params[1]) || empty($p_field_params[1]))
|
792
|
{
|
793
|
$p_field_params[0]['table'] = false;
|
794
|
return;
|
795
|
}
|
796
|
|
797
|
$c_image_nr = (int) $p_field_params[1];
|
798
|
$p_field_params[0]['table'] = 'gm_prd_img_alt';
|
799
|
$t_temp = $p_field_params[0]['value'];
|
800
|
$p_field_params[0]['value'] = array();
|
801
|
$p_field_params[0]['value'][$c_image_nr] = $t_temp;
|
802
|
}
|
803
|
|
804
|
protected function additional_level(&$p_field_params, $p_param_position = 1)
|
805
|
{
|
806
|
if (!isset($p_field_params[$p_param_position]) || empty($p_field_params[$p_param_position]))
|
807
|
{
|
808
|
return;
|
809
|
}
|
810
|
$c_index = (int) $p_field_params[$p_param_position];
|
811
|
$t_temp = $p_field_params[0]['value'];
|
812
|
$p_field_params[0]['value'] = array();
|
813
|
$p_field_params[0]['value'][$c_index] = $t_temp;
|
814
|
}
|
815
|
|
816
|
protected function resolve_c_path(&$p_field_params)
|
817
|
{
|
818
|
if (!isset($this->v_language_array[$p_field_params[1]]) || empty($this->v_language_array[$p_field_params[1]]))
|
819
|
{
|
820
|
$p_field_params[0]['table'] = false;
|
821
|
return;
|
822
|
}
|
823
|
if (!isset($p_field_params[0]['table']) || empty($p_field_params[0]['table']) || empty($p_field_params[0]['value']))
|
824
|
{
|
825
|
return;
|
826
|
}
|
827
|
if (!array_key_exists($p_field_params[0]['table'], $this->v_import_data_array))
|
828
|
{
|
829
|
$this->v_import_data_array[$p_field_params[0]['table']] = array();
|
830
|
}
|
831
|
|
832
|
// //TODO: Optimierung (c_path nur f�r eine Sprache aufl�sen)
|
833
|
// if (array_key_exists($p_field_params[0]['column'], $this->v_import_data_array[$p_field_params[0]['table']]))
|
834
|
// {
|
835
|
// $this->ignore_column($p_field_params);
|
836
|
// return;
|
837
|
// }
|
838
|
|
839
|
$t_category_array = explode('>', $p_field_params[0]['value']);
|
840
|
|
841
|
$i = 0;
|
842
|
$t_sql = "";
|
843
|
$t_sql_select = "SELECT";
|
844
|
$t_sql_from = " FROM";
|
845
|
$t_sql_where = "";
|
846
|
$t_sql_limit = " LIMIT 1";
|
847
|
|
848
|
for ($i = 1; $i <= count($t_category_array); $i++)
|
849
|
{
|
850
|
if (strpos_wrapper($t_category_array[$i - 1], '[') !== false && strpos_wrapper($t_category_array[$i - 1], ']') !== false)
|
851
|
{
|
852
|
$t_categories_id = substr_wrapper($t_category_array[$i - 1], strpos_wrapper($t_category_array[$i - 1], '[') + 1);
|
853
|
$t_categories_id = trim(substr_wrapper($t_categories_id, 0, strpos_wrapper($t_categories_id, ']')));
|
854
|
$t_identification_sql = "c.categories_id = " . $t_categories_id;
|
855
|
}
|
856
|
else
|
857
|
{
|
858
|
$t_identification_sql = "cd.categories_name LIKE '" . trim($t_category_array[$i - 1]) . "'";
|
859
|
}
|
860
|
|
861
|
$t_sql_subselect = "SELECT
|
862
|
c.categories_id,
|
863
|
c.parent_id,
|
864
|
cd.categories_name
|
865
|
FROM
|
866
|
categories c,
|
867
|
categories_description cd
|
868
|
WHERE
|
869
|
c.categories_id = cd.categories_id
|
870
|
AND
|
871
|
" . $t_identification_sql . "
|
872
|
AND
|
873
|
cd.language_id = " . $this->v_language_array[$p_field_params[1]];
|
874
|
|
875
|
if ($i > 1)
|
876
|
{
|
877
|
$t_sql_from .= " LEFT JOIN (" . $t_sql_subselect . ") as level" . $i . " ON (level" . $i . ".parent_id = level" . ($i - 1) . ".categories_id)";
|
878
|
$t_sql_select .= ($i > 1 ? "," : "") . "
|
879
|
level" . $i . ".categories_id as level" . $i . "_categories_id,
|
880
|
level" . $i . ".categories_name as level" . $i . "_categories_name";
|
881
|
}
|
882
|
else
|
883
|
{
|
884
|
$t_sql_from .= " (" . $t_sql_subselect . ") as level" . $i;
|
885
|
$t_sql_select .= "
|
886
|
level" . $i . ".categories_id as level" . $i . "_categories_id,
|
887
|
level" . $i . ".categories_name as level" . $i . "_categories_name";
|
888
|
$t_sql_where .= " WHERE level" . $i . ".parent_id = 0";
|
889
|
}
|
890
|
}
|
891
|
$t_sql = $t_sql_select . $t_sql_from . $t_sql_where . $t_sql_limit;
|
892
|
|
893
|
$t_result = xtc_db_query($t_sql, 'db_link', false);
|
894
|
$t_category_path = array();
|
895
|
if(xtc_db_num_rows($t_result) == 1)
|
896
|
{
|
897
|
$t_category_path = xtc_db_fetch_array($t_result);
|
898
|
}
|
899
|
|
900
|
for ($i = 1; $i <= count($t_category_array); $i++)
|
901
|
{
|
902
|
$t_category_id = substr_wrapper($t_category_array[$i - 1], strpos_wrapper($t_category_array[$i - 1], '[') + 1);
|
903
|
$t_category_id = substr_wrapper($t_category_id, 0, strpos_wrapper($t_category_id, ']'));
|
904
|
|
905
|
if (strpos_wrapper($t_category_array[$i - 1], '[') !== false)
|
906
|
{
|
907
|
$t_category_array[$i - 1] = substr_wrapper($t_category_array[$i - 1], 0, strpos_wrapper($t_category_array[$i - 1], '['));
|
908
|
}
|
909
|
|
910
|
if (empty($t_category_id))
|
911
|
{
|
912
|
if (isset($t_category_path['level' . $i . '_categories_id']))
|
913
|
{
|
914
|
$t_category_id = $t_category_path['level' . $i . '_categories_id'];
|
915
|
}
|
916
|
else
|
917
|
{
|
918
|
$t_category_id = '';
|
919
|
}
|
920
|
}
|
921
|
|
922
|
$this->set_field_content('categories_id.' . $i, $t_category_id);
|
923
|
|
924
|
if((!empty($t_category_id) && $i > 1) || empty($t_category_id))
|
925
|
{
|
926
|
$this->set_field_content('parent_id.' . $i, (isset($t_category_path['level' . ($i - 1) . '_categories_id'])) ? $t_category_path['level' . ($i - 1) . '_categories_id'] : 0);
|
927
|
}
|
928
|
else
|
929
|
{
|
930
|
$this->set_field_content('parent_id.1', 0);
|
931
|
}
|
932
|
|
933
|
$this->set_field_content('categories_status.' . $i, 1);
|
934
|
$this->set_field_content('date_added.' . $i, 'now()');
|
935
|
$this->set_field_content('last_modified.' . $i, 'now()');
|
936
|
$this->set_field_content('categories_name.' . $i . '.' . $p_field_params[1], $t_category_array[$i - 1]);
|
937
|
$this->set_field_content('categories_description_id.' . $i . '.' . $p_field_params[1], $t_category_path['level' . $i . '_categories_id']);
|
938
|
}
|
939
|
$p_field_params[0]['value'] = $t_category_id;
|
940
|
}
|
941
|
|
942
|
protected function convert_google_export_availability(&$p_field_params)
|
943
|
{
|
944
|
if (empty($this->v_google_export_availability_array))
|
945
|
{
|
946
|
$this->build_google_export_availability_array();
|
947
|
}
|
948
|
if (!empty($p_field_params[0]['value']))
|
949
|
{
|
950
|
$p_field_params[0]['value'] = $this->v_google_export_availability_array[$p_field_params[0]['value']];
|
951
|
}
|
952
|
}
|
953
|
|
954
|
protected function property(&$p_field_params)
|
955
|
{
|
956
|
if (empty($this->v_import_data_array['products']['products_id']) || empty($p_field_params[0]['value']))
|
957
|
{
|
958
|
$this->ignore_column($p_field_params);
|
959
|
return;
|
960
|
}
|
961
|
|
962
|
if (empty($this->v_properties))
|
963
|
{
|
964
|
$this->v_csv_source = MainFactory::create_object('CSVSource', array(), true);
|
965
|
$this->v_properties = $this->v_csv_source->get_properties_array();
|
966
|
}
|
967
|
|
968
|
$c_property_id = $this->get_property_id($p_field_params[0]['property']);
|
969
|
|
970
|
if (empty($c_property_id))
|
971
|
{
|
972
|
$this->ignore_column($p_field_params);
|
973
|
return;
|
974
|
}
|
975
|
|
976
|
if (empty($this->v_language_array))
|
977
|
{
|
978
|
$this->build_language_array();
|
979
|
}
|
980
|
|
981
|
$c_property_value_name = $this->get_property_value_name($p_field_params[0]['value']);
|
982
|
$c_property_value_id = (int) $this->get_property_value_id($c_property_id, $p_field_params[0]['value'], $p_field_params[1]);
|
983
|
|
984
|
$this->set_field_content('properties_values-properties_values_id.' . $c_property_id, $c_property_value_id);
|
985
|
$this->set_field_content('properties_values-properties_id.' . $c_property_id, $c_property_id);
|
986
|
|
987
|
$this->set_field_content('properties_values_description-properties_values_id.' . $c_property_id, $c_property_value_id);
|
988
|
$this->set_field_content('properties_values_description-language_id.' . $c_property_id, $this->v_language_array[trim($p_field_params[1])]);
|
989
|
$this->set_field_content('properties_values_description-values_name.' . $c_property_id, $c_property_value_name);
|
990
|
|
991
|
$this->set_field_content('products_properties_combis_values-properties_values_id.' . $c_property_id, $c_property_value_id);
|
992
|
|
993
|
$this->set_field_content('products_properties_admin_select-properties_id.' . $c_property_id, $c_property_id);
|
994
|
$this->set_field_content('products_properties_admin_select-properties_values_id.' . $c_property_id, $c_property_value_id);
|
995
|
}
|
996
|
|
997
|
|
998
|
protected function get_property_id($p_property)
|
999
|
{
|
1000
|
if (strpos_wrapper($p_property, '[') !== false && strpos_wrapper($p_property, ']') !== false)
|
1001
|
{
|
1002
|
$p_property = substr_wrapper($p_property, strpos_wrapper($p_property, '[') + 1);
|
1003
|
$p_property = trim(substr_wrapper($p_property, 0, strpos_wrapper($p_property, ']')));
|
1004
|
$c_property_id = (int) $p_property;
|
1005
|
}
|
1006
|
else if (isset($this->v_properties_by_name_array[$p_property]) && !empty($this->v_properties_by_name_array[$p_property]))
|
1007
|
{
|
1008
|
$c_property_id = $this->v_properties_by_name_array[$p_property];
|
1009
|
}
|
1010
|
else if (isset($this->v_properties_by_name_array[$p_property]) && empty($this->v_properties_by_name_array[$p_property]))
|
1011
|
{
|
1012
|
return 0;
|
1013
|
}
|
1014
|
else
|
1015
|
{
|
1016
|
$t_sql = " SELECT
|
1017
|
properties_id
|
1018
|
FROM
|
1019
|
properties_description
|
1020
|
WHERE
|
1021
|
properties_name LIKE '" . $p_property . "'";
|
1022
|
$t_result = xtc_db_query($t_sql);
|
1023
|
|
1024
|
if (xtc_db_num_rows($t_result) != 1)
|
1025
|
{
|
1026
|
$this->v_properties_by_name_array[$p_property] = 0;
|
1027
|
return 0;
|
1028
|
}
|
1029
|
|
1030
|
$t_row = xtc_db_fetch_array($t_result);
|
1031
|
$c_property_id = (int) $t_row['properties_id'];
|
1032
|
$this->v_properties_by_name_array[$p_property] = $c_property_id;
|
1033
|
}
|
1034
|
|
1035
|
return $c_property_id;
|
1036
|
}
|
1037
|
|
1038
|
protected function get_property_value_id($p_property_id, $p_property_value, $p_language_code = 'de')
|
1039
|
{
|
1040
|
$t_language_code = trim($p_language_code);
|
1041
|
if (strpos_wrapper($p_property_value, '[') !== false && strpos_wrapper($p_property_value, ']') !== false)
|
1042
|
{
|
1043
|
$p_property_value = substr_wrapper($p_property_value, strpos_wrapper($p_property_value, '[') + 1);
|
1044
|
$p_property_value = trim(substr_wrapper($p_property_value, 0, strpos_wrapper($p_property_value, ']')));
|
1045
|
$c_property_value_id = (int) $p_property_value;
|
1046
|
}
|
1047
|
else if (isset($this->v_property_values_by_name_array[$p_property_id][$t_language_code][$p_property_value]) && !empty($this->v_property_values_by_name_array[$p_property_id][$t_language_code][$p_property_value]))
|
1048
|
{
|
1049
|
$c_property_value_id = $this->v_property_values_by_name_array[$p_property_id][$t_language_code][$p_property_value];
|
1050
|
}
|
1051
|
else if (isset($this->v_property_values_by_name_array[$p_property_id][$t_language_code][$p_property_value]) && empty($this->v_property_values_by_name_array[$p_property_id][$t_language_code][$p_property_value]))
|
1052
|
{
|
1053
|
return 0;
|
1054
|
}
|
1055
|
else
|
1056
|
{
|
1057
|
$c_property_value_name = $this->get_property_value_name($p_property_value);
|
1058
|
if (empty($this->v_language_array))
|
1059
|
{
|
1060
|
$this->build_language_array();
|
1061
|
}
|
1062
|
|
1063
|
$t_sql = " SELECT
|
1064
|
pvd.properties_values_id,
|
1065
|
pvd.language_id
|
1066
|
FROM
|
1067
|
properties_values pv,
|
1068
|
properties_values_description pvd
|
1069
|
WHERE
|
1070
|
pv.properties_id = " . $p_property_id . "
|
1071
|
AND
|
1072
|
pv.properties_values_id = pvd.properties_values_id
|
1073
|
AND
|
1074
|
pvd.values_name LIKE '" . $c_property_value_name . "'
|
1075
|
AND
|
1076
|
pvd.language_id = " . $this->v_language_array[$t_language_code];
|
1077
|
$t_result = xtc_db_query($t_sql);
|
1078
|
|
1079
|
if (xtc_db_num_rows($t_result) != 1)
|
1080
|
{
|
1081
|
$this->v_property_values_by_name_array[$p_property_id][$t_language_code][$c_property_value_name] = 0;
|
1082
|
return 0;
|
1083
|
}
|
1084
|
|
1085
|
$t_row = xtc_db_fetch_array($t_result);
|
1086
|
$c_property_value_id = (int) $t_row['properties_values_id'];
|
1087
|
$this->v_property_values_by_name_array[$p_property_id][$t_language_code][$c_property_value_name] = $c_property_value_id;
|
1088
|
}
|
1089
|
|
1090
|
return $c_property_value_id;
|
1091
|
}
|
1092
|
|
1093
|
protected function get_additional_field_id($p_additional_field_headline)
|
1094
|
{
|
1095
|
$c_additional_field_id = 0;
|
1096
|
|
1097
|
if (strpos_wrapper($p_additional_field_headline, '[') !== false && strpos_wrapper($p_additional_field_headline, ']') !== false)
|
1098
|
{
|
1099
|
$p_additional_field_headline = substr_wrapper($p_additional_field_headline, strpos_wrapper($p_additional_field_headline, '[') + 1);
|
1100
|
$p_additional_field_headline = trim(substr_wrapper($p_additional_field_headline, 0, strpos_wrapper($p_additional_field_headline, ']')));
|
1101
|
$c_additional_field_id = (int) $p_additional_field_headline;
|
1102
|
}
|
1103
|
|
1104
|
return $c_additional_field_id;
|
1105
|
}
|
1106
|
|
1107
|
|
1108
|
protected function get_additional_field_value_id($p_additional_field_id, $p_item_id, $p_language_id = 0)
|
1109
|
{
|
1110
|
$t_additional_field_value_id = 0;
|
1111
|
if(isset($this->v_additional_fields[$p_additional_field_id][$p_item_id][$p_language_id]['additional_field_value_id']))
|
1112
|
{
|
1113
|
$t_additional_field_value_id = $this->v_additional_fields[$p_additional_field_id][$p_item_id][$p_language_id]['additional_field_value_id'];
|
1114
|
}
|
1115
|
|
1116
|
return $t_additional_field_value_id;
|
1117
|
}
|
1118
|
|
1119
|
protected function get_property_value_name($p_property_value)
|
1120
|
{
|
1121
|
return trim(substr_wrapper($p_property_value, 0, strpos_wrapper($p_property_value, '[') ? strpos_wrapper($p_property_value, '[') : strlen_wrapper($p_property_value)));
|
1122
|
}
|
1123
|
|
1124
|
protected function ignore_column(&$p_field_params)
|
1125
|
{
|
1126
|
$p_field_params[0]['table'] = '';
|
1127
|
}
|
1128
|
|
1129
|
protected function additional_field(&$p_field_params)
|
1130
|
{
|
1131
|
if (empty($this->v_import_data_array['products']['products_id']) || empty($p_field_params[0]['value']))
|
1132
|
{
|
1133
|
$this->ignore_column($p_field_params);
|
1134
|
return;
|
1135
|
}
|
1136
|
|
1137
|
if (empty($this->v_additional_fields))
|
1138
|
{
|
1139
|
$this->v_csv_source = MainFactory::create_object('CSVSource', array(), true);
|
1140
|
$this->v_additional_fields = $this->v_csv_source->get_additional_fields_array();
|
1141
|
}
|
1142
|
|
1143
|
$c_additional_field_id = $this->get_additional_field_id($p_field_params[0]['additional_field']);
|
1144
|
|
1145
|
if (empty($c_additional_field_id))
|
1146
|
{
|
1147
|
$this->ignore_column($p_field_params);
|
1148
|
return;
|
1149
|
}
|
1150
|
|
1151
|
if (empty($this->v_language_array))
|
1152
|
{
|
1153
|
$this->build_language_array();
|
1154
|
}
|
1155
|
|
1156
|
$t_language_id = 0;
|
1157
|
$t_language_code = '';
|
1158
|
if(isset($p_field_params[1]))
|
1159
|
{
|
1160
|
$t_language_id = $this->v_language_array[trim($p_field_params[1])];
|
1161
|
$t_language_code = '.' . trim($p_field_params[1]);
|
1162
|
}
|
1163
|
|
1164
|
$c_additional_field_value_id = $this->get_additional_field_value_id($c_additional_field_id, $this->v_import_data_array['products']['products_id'], $t_language_id);
|
1165
|
|
1166
|
$this->set_field_content('additional_field_values-additional_field_value_id.' . $c_additional_field_id, $c_additional_field_value_id);
|
1167
|
$this->set_field_content('additional_field_values-additional_field_id.' . $c_additional_field_id, $c_additional_field_id);
|
1168
|
|
1169
|
$this->set_field_content('additional_field_value_descriptions-additional_field_value_id.' . $c_additional_field_id . $t_language_code, $c_additional_field_value_id);
|
1170
|
$this->set_field_content('additional_field_value_descriptions-language_id.' . $c_additional_field_id . $t_language_code, $t_language_id);
|
1171
|
$this->set_field_content('additional_field_value_descriptions-value.' . $c_additional_field_id . $t_language_code, $p_field_params[0]['value']);
|
1172
|
}
|
1173
|
|
1174
|
protected function by_additional_field_and_language(&$p_field_params)
|
1175
|
{
|
1176
|
|
1177
|
}
|
1178
|
}
|