· 6 years ago · Mar 12, 2020, 10:38 AM
1var versaImporter = new _flatfileCsvImporter.default("4171f0b4-5f5c-4b32-a008-356ebb813e4e", // Put your license key in to show imports on your client dashboard
2{
3 fields: [{
4 key: "code",
5 alternates: ["sku", "productcode", "produktnummer", "artikelnummer"],
6 label: "Artikelnummer",
7 // EN - Article number
8 description: "Der Code unter dem das Produkt im System geführt wird",
9 // EN - The code under which the product is listed in the system
10 validators: [{
11 validate: "required"
12 }]
13 }, {
14 key: "title",
15 alternates: ["name", "productname", "titel"],
16 label: "Titel",
17 // EN - Title
18 description: "Name des Produkts",
19 // EN - Name of the product
20 validators: [{
21 validate: "required"
22 }]
23 }, {
24 key: "gtin",
25 alternates: ["ean"],
26 label: "GTIN",
27 // EN - GTIN
28 description: "GTIN des Produkts",
29 // EN - GTIN of the product
30 validators: [{
31 validate: "regex_matches",
32 regex: "^[0-9]*$",
33 error: "Muss ganze Zahl sein"
34 }]
35 }, {
36 key: "price",
37 alternates: ["preis"],
38 label: "Preis",
39 // EN - Price
40 description: "Preis des Produkts" // EN - Price of the product
41 // formatted with the data hooks below
42 // strip everything - treturn float
43
44 }, {
45 key: "code_of_parent",
46 label: "Hauptprodukt Artikelnummer",
47 // EN - Article number Main product
48 description: "Artikelnummer des Hauptprodukts" // EN - Article number of the Main product
49 // For validation here, we can use a column hook (example below)
50 // to batch this entire column and validate it against an external
51 // data source (ie. you can send to your server and then provide feedback
52 // and send it back)
53
54 }, {
55 key: "compare_at_price",
56 alternates: ["streichpreis", "vergleichspreis", "alter preis"],
57 label: "Streichpreis",
58 // EN - Compare at price
59 description: "Streichpreis des Produkts" // EN - Compare price of the product
60 // formatted with data hooks below
61
62 }, {
63 key: "subtitle",
64 alternates: ["untertitel"],
65 label: "Untertitel",
66 // EN - Subtitle
67 description: "Untertitel des Produkts" // EN - Subtitle of the product
68
69 }, {
70 key: "description",
71 alternates: ["beschreibung"],
72 label: "Beschreibung",
73 // EN - Description
74 description: "Beschreibung des Produkts" // EN - Description of the product
75
76 }, {
77 key: "vendor",
78 alternates: ["hersteller", "verkäufer"],
79 label: "Hersteller",
80 // EN - Vendor
81 description: "Hersteller des Produkts" // EN - Vendor of the product
82
83 }, {
84 key: "category",
85 alternates: ["kategorie", "typ", "art"],
86 label: "Kategorie",
87 // EN - Category
88 description: "Produktkategorie" // EN - Product category
89
90 }, {
91 key: "weight",
92 alternates: ["gewicht"],
93 label: "Gewicht",
94 //EN - Weight
95 description: "Produktgewicht" // EN -Product weight
96
97 }, {
98 key: "stock",
99 alternates: ["bestand", "anzahl", "stückzahl", "stück"],
100 label: "Bestand",
101 // EN - Stock
102 description: "Produktbestand",
103 // EN - Product stock
104 validators: [{
105 validate: "regex_matches",
106 regex: "^[0-9]*$",
107 error: "Muss ganze Zahl sein"
108 }]
109 }, {
110 key: "base_unit",
111 alternates: ["mengeneinheit", "einheit", "grundeinheit"],
112 label: "Grundmengeneinheit",
113 // EN - Basic unit of measure
114 description: "Mengeneinheit des Produkts" // EN - Unit of measure of the product
115
116 }, {
117 key: "visible",
118 alternates: ["sichtbar"],
119 label: "Sichtbar",
120 // EN - Visible
121 description: "Soll das Produkt im Online Shop sichtbar sein",
122 // EN - Should the product be visible
123 type: "checkbox"
124 }, {
125 key: "active",
126 alternates: ["online", "aktiv"],
127 label: "Aktiv",
128 // EN - Active
129 description: "Soll das Produkt im Online Shop aktiv sein",
130 // EN - Should the product be active
131 type: "checkbox"
132 }, {
133 key: "considers_stock",
134 label: "Bestand berücksichtigen",
135 // EN - Consider stock
136 description: "Produktbestand berücksichtigen",
137 // EN - Should the stock be considered "
138 type: "checkbox"
139 }, {
140 key: "shows_stock_amount",
141 label: "Bestand anzeigen",
142 // EN - Show stock amount
143 description: "Produktbestand angezeigen",
144 // EN - Should the stock amount be visible "
145 type: "checkbox"
146 }, {
147 key: "featured",
148 alternates: ["vorgestellt", "angebot"],
149 label: "Top",
150 /// EN - Featured product
151 description: "Ist das Produkt ein Top-Produkt",
152 // EN - Is the product a featured product "
153 type: "checkbox"
154 }, {
155 key: "new",
156 alternates: ["neu"],
157 label: "Neues Produkt",
158 // EN - New product
159 description: "Ist das Produkt ein neues Produkt",
160 // EN - Is the product a new product "
161 type: "checkbox"
162 }, {
163 key: "base_quantity",
164 alternates: ["menge"],
165 label: "Grundmenge",
166 // EN - Basic quantitiy
167 description: "Die Menge, auf die sich die Grundpreisrechnung bezieht",
168 // EN - The number of packaging units in a package "
169 validators: [{
170 validate: "regex_matches",
171 regex: "^[0-9]*$",
172 error: "Muss ganze Zahl sein"
173 }]
174 }, {
175 key: "base_quantity_sold",
176 label: "Verpackungseinheit in stück",
177 // EN - Packaging unit in pieces
178 description: "Die Anzahl der Einheituen in einer Verpackung",
179 // EN - The quantity to which the basic price calculation refers "
180 validators: [{
181 validate: "regex_matches",
182 regex: "^[0-9]*$",
183 error: "Muss ganze Zahl sein"
184 }]
185 }, {
186 key: "base_quantity_package",
187 label: "Menge pro Verpackungseinheit",
188 // EN - Packaging unit
189 description: "Anzahl der Mengeneinheiten, die sich in einer Verpackung befinden",
190 // EN - The proportion of the unit of measure that is in a package "
191 validators: [{
192 validate: "regex_matches",
193 regex: "^[0-9]*$",
194 error: "Muss ganze Zahl sein"
195 }]
196 }, {
197 key: "base_perform_calculation",
198 label: "Grundpreisberechnung",
199 // EN - Basic price calculation
200 description: "Soll der Grundpreis berechnet werden",
201 // EN - Should the basic price be calculated "
202 type: "checkbox"
203 }, {
204 key: "packaging_duration",
205 alternates: ["packzeit"],
206 label: "Packzeit in Stunden",
207 // EN - Packaging duration in hours
208 description: "Packzeit in Stunden",
209 // EN - Packaging duration in hours "
210 validators: [{
211 validate: "regex_matches",
212 regex: "^[0-9]*$",
213 error: "Muss ganze Zahl sein"
214 }]
215 }, {
216 key: "option_01_label",
217 label: "Option_01_Bezeichnung",
218 // EN - Option_01_Description
219 description: "Bezeichnung der ersten Produkt Option",
220 // EN - Description of the first product option "
221 validators: [{
222 validate: "required_with",
223 fields: ["option_02_label", "option_03_label"]
224 }]
225 }, {
226 key: "option_02_label",
227 label: "Option_02_Bezeichnung",
228 // EN - Option_02_Description
229 description: "Bezeichnung der zweiten Produkt Option",
230 // EN - Description of the second product option
231 validators: [{
232 validate: "required_with",
233 fields: ["option_03_label"]
234 }]
235 }, {
236 key: "option_03_label",
237 label: "Option_03_Bezeichnung",
238 // EN - Option_03_Description
239 description: "Bezeichnung der dritten Produkt Option" // EN - Description of the third product option
240
241 }, {
242 key: "option_01",
243 label: "Option_01_Wert",
244 // EN - Option_01_Value
245 description: "Wert der ersten Produkt Option",
246 // EN - Value of the first product option
247 validators: [{
248 validate: "required_with",
249 fields: ["option_02", "option_03"]
250 }]
251 }, {
252 key: "option_02",
253 label: "Option_02_Wert",
254 // EN - Option_02_Value
255 description: "Wert der zweiten Produkt Option",
256 // EN - Value of the second product option
257 validators: [{
258 validate: "required_with",
259 fields: ["option_03"]
260 }]
261 }, {
262 key: "option_03",
263 label: "Option_03_Wert",
264 // EN - Option_03_Value
265 description: "Wert der dritten Produkt Option" // EN - Value of the third product option
266
267 }, {
268 key: "handle",
269 alternates: ["permalink"],
270 label: "Permalink",
271 // EN - Permalink
272 description: "Permalink des produkts" // EN - Permalink of the product
273
274 }, {
275 key: "custom_url",
276 label: "Benutzerdefinierte URL",
277 // EN - Custom URL
278 description: "Benutzerdefinierte URL für das Produkt" // EN - Custom URL for the product
279
280 }, {
281 key: "content_title_tag",
282 label: "Metatitel",
283 // EN - Content Title-Tag
284 description: "Inhalt des Title-Tags" // EN - Content of the Title-Tag
285
286 }, {
287 key: "content_meta_description",
288 label: "Metabeschreibung",
289 // EN - Content Description-Tag
290 description: "Inhalt des Decription-Tags" // EN - Content of the Description-Tag
291
292 }, {
293 key: "content_meta_keywords",
294 label: "Inhalt Keywords-Tag",
295 // EN - Content Keywords-Tag
296 description: "Inhalt des Keyword-Tags" // EN - Content of the Keywords-Tag
297
298 }, {
299 key: "image_url_1",
300 label: "Bild_url_1",
301 // EN - Image_url_1
302 description: "URL des ersten Bildes",
303 // EN - URL of the first image
304 validators: [{
305 validate: "required_with",
306 fields: ["image_url_2", "image_url_3"],
307 error: "Bild_url_1 muss gesetzt sein, um Bild_url_2 oder 3 zu nutzen"
308 }]
309 }, {
310 key: "image_url_2",
311 label: "Bild_url_2",
312 // EN - Image_url_2
313 description: "URL des zweiten Bildes",
314 // EN - URL of the second image
315 validators: [{
316 validate: "required_with",
317 fields: ["image_url_3"],
318 error: "Bild_url_2 muss gesetzt sein, um Bild_url_3 zu nutzen"
319 }]
320 }, {
321 key: "image_url_3",
322 label: "Bild_url_3",
323 // EN - Image_url_3
324 description: "URL des dritten Bildes" // EN - URL of the third image
325
326 }, {
327 key: "property_key_1",
328 label: "Attribut-Schlüssel 1",
329 // EN - Property-Key 1
330 description: "Eigenschaften-Bezeichnung 1" // EN - Property-Description 1
331
332 }, {
333 key: "property_value_1",
334 label: "Attribut-Wert 1",
335 // EN - Property-Value 1
336 description: "Eigenschaften-Wert 1" // EN - Property-Value 1
337
338 }, {
339 key: "property_key_2",
340 label: "Attribut-Schlüssel 2",
341 // EN - Property-Key 2
342 description: "Eigenschaften-Bezeichnung 2" // EN - Property-Description 2
343
344 }, {
345 key: "property_value_2",
346 label: "Attribut-Wert 2",
347 // EN - Property-Value 2
348 description: "Eigenschaften-Wert 2" // EN - Property-Value 2
349
350 }, {
351 key: "property_key_3",
352 label: "Attribut-Schlüssel 3",
353 // EN - Property-Key 3
354 description: "Eigenschaften-Bezeichnung 3" // EN - Property-Description 3
355
356 }, {
357 key: "property_value_3",
358 label: "Attribut-Wert 3",
359 // EN - Property-Value 3
360 description: "Eigenschaften-Wert 4" // EN - Property-Value 3
361
362 }, {
363 key: "recommended_product_code_1",
364 label: "Produktempfehlung 1 Artikelnummer",
365 // EN - Recommended Product Article number 1
366 description: "Artikelnummer der ersten Produktempfehlung" // EN - Article number of the first recommended product
367
368 }, {
369 key: "recommended_product_description_1",
370 label: "Produktempfehlung 1 Beschreibung",
371 // EN - Recommended Product description 1
372 description: "Beschreibung der ersten Produktempfehlung" // EN - Description of the first recommended product
373
374 }, {
375 key: "recommended_product_code_2",
376 label: "Produktempfehlung 2 Artikelnummer",
377 // EN - Recommended Product Article number 2
378 description: "Artikelnummer der zweiten Produktempfehlung" // EN - Article number of the second recommended product
379
380 }, {
381 key: "recommended_product_description_2",
382 label: "Produktempfehlung 2 Beschreibung",
383 // EN - Recommended Product description 2
384 description: "Beschreibung der zweiten Produktempfehlung" // EN - Description of the second recommended product
385
386 }, {
387 key: "recommended_product_code_3",
388 label: "Produktempfehlung 3 Artikelnummer",
389 // EN - Recommended Product Article number 3
390 description: "Artikelnummer der dritten Produktempfehlung" // EN - Article number of the third recommended product
391
392 }, {
393 key: "recommended_product_description_3",
394 label: "Produktempfehlung 3 Beschreibung",
395 // EN - Recommended Product description 3
396 description: "Beschreibung der dritten Produktempfehlung" // EN - Description of the third recommended product
397
398 }],
399 type: "Products",
400 allowInvalidSubmit: false,
401 // being set to false, the end user has to fix all the issues for the data before submitting to you all
402 managed: true,
403 // this gives you access to see impoorts on our dashboard
404 allowCustom: true,
405 // this lets your users upload a custom column that you haven't accounted for in the above fields
406 disableManualInput: false // this would let someone manually input the data instead of uploading a file
407
408}); // here is a good example column hook using our dummy API
409
410var codes;
411versaImporter.registerFieldHook("code", function (values) {
412 codes = values;
413 return values;
414});
415versaImporter.registerRecordHook(function (record, index) {
416 var out = {}; // below are used to make sure price is a float value without the € symbol
417
418 if (record.price) {
419 console.log("original format: ", record.price);
420 var formatCurrency = (0, _functions.makeFloat)(record.price);
421 out.price = {
422 value: formatCurrency
423 };
424 }
425
426 if (record.compare_at_price) {
427 console.log("original format: ", record.compare_at_price);
428
429 var _formatCurrency = (0, _functions.makeFloat)(record.compare_at_price);
430
431 out.compare_at_price = {
432 value: _formatCurrency
433 };
434 }
435
436 if (record.weight) {
437 if (!record.weight.includes(".")) {
438 out.weight = {
439 value: record.weight + ".0",
440 info: [{
441 message: "formatted to a decimal",
442 level: "info"
443 }]
444 };
445 }
446 } // below used to verify that image urls don't contain versacommerce.de
447
448
449 if (record.image_url_1) {
450 if (record.image_url_1.toLowerCase().includes("versacommerce.de")) {
451 out.image_url_1 = {
452 info: [{
453 message: "Cannot upload images from versacommerce.de",
454 level: "error"
455 }]
456 };
457 }
458 }
459
460 if (record.image_url_2) {
461 if (record.image_url_2.toLowerCase().includes("versacommerce.de")) {
462 out.image_url_2 = {
463 info: [{
464 message: "Cannot upload images from versacommerce.de",
465 level: "error"
466 }]
467 };
468 }
469 }
470
471 if (record.image_url_3) {
472 if (record.image_url_3.toLowerCase().includes("versacommerce.de")) {
473 out.image_url_3 = {
474 info: [{
475 message: "Cannot upload images from versacommerce.de",
476 level: "error"
477 }]
478 };
479 }
480 }
481
482 if (record.code_of_parent) {
483 if (codes && !codes.includes(record.code_of_parent)) {
484 out.code_of_parent = {
485 info: [{
486 message: "Only fill in this field if the main product already exists in your shop (or this table)",
487 level: "warning"
488 }]
489 };
490 }
491 }
492
493 return out;
494});