@shushed/helpers 0.0.265 → 0.0.267
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -336,10 +336,14 @@ class FredHelperBase {
|
|
|
336
336
|
for (const variant of variants) {
|
|
337
337
|
const { id, ...rest } = variant;
|
|
338
338
|
Object.entries(rest).forEach(([key, value]) => {
|
|
339
|
-
const
|
|
340
|
-
|| this.attributes.find(a => a.attribute_id === key)?.type === 'set' || this.attributes.find(a => a.attribute_id === key)?.type === 'set64'
|
|
341
|
-
|
|
342
|
-
|
|
339
|
+
const isMultivalue = this.attributes.find(a => a.attribute_id === key)?.type === 'list'
|
|
340
|
+
|| this.attributes.find(a => a.attribute_id === key)?.type === 'set' || this.attributes.find(a => a.attribute_id === key)?.type === 'set64';
|
|
341
|
+
const asArr = Array.isArray(value) && isMultivalue ? value : [value];
|
|
342
|
+
for (let i = 0; i < asArr.length; i++) {
|
|
343
|
+
if (asArr[i]) {
|
|
344
|
+
lines.push(this.createCSVLine(variant.id, 'en_GB', key, `_${Array.isArray(asArr[i]) ? asArr[i].map((v) => `_${v}`).join(' | ') : `_${asArr[i]}`}`, String(Array.isArray(asArr[i]) ? asArr[i].join(' | ') : value)));
|
|
345
|
+
}
|
|
346
|
+
}
|
|
343
347
|
});
|
|
344
348
|
}
|
|
345
349
|
});
|
|
@@ -361,14 +365,13 @@ class FredHelperBase {
|
|
|
361
365
|
if (!value) {
|
|
362
366
|
continue;
|
|
363
367
|
}
|
|
364
|
-
const
|
|
365
|
-
|| this.attributes.find(a => a.attribute_id === attributeId)?.type === 'set' || this.attributes.find(a => a.attribute_id === attributeId)?.type === 'set64'
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
lines.push(this.createCSVLine(product.product_id, 'en_GB', attributeId, valueId, valueStr));
|
|
368
|
+
const isMultivalue = this.attributes.find(a => a.attribute_id === attributeId)?.type === 'list'
|
|
369
|
+
|| this.attributes.find(a => a.attribute_id === attributeId)?.type === 'set' || this.attributes.find(a => a.attribute_id === attributeId)?.type === 'set64';
|
|
370
|
+
const asArr = Array.isArray(value) && isMultivalue ? value : [value];
|
|
371
|
+
for (let i = 0; i < asArr.length; i++) {
|
|
372
|
+
if (asArr[i]) {
|
|
373
|
+
lines.push(this.createCSVLine(product.product_id, 'en_GB', attributeId, `_${Array.isArray(asArr[i]) ? asArr[i].map((v) => `_${v}`).join(' | ') : `_${asArr[i]}`}`, String(Array.isArray(asArr[i]) ? asArr[i].join(' | ') : value)));
|
|
374
|
+
}
|
|
372
375
|
}
|
|
373
376
|
}
|
|
374
377
|
}
|