@haus-tech/product-export-plugin 2.2.2 → 2.2.3
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.
|
@@ -116,8 +116,9 @@ let ProductExportService = class ProductExportService {
|
|
|
116
116
|
const descriptionTranslations = this.mapTranslations(translations, 'description', languages);
|
|
117
117
|
// Filter out all variants that are soft deleted
|
|
118
118
|
const activeVariants = variants.filter((v) => !v.deletedAt);
|
|
119
|
-
const productAssets = assets.length === 0
|
|
120
|
-
|
|
119
|
+
const productAssets = assets.length === 0
|
|
120
|
+
? ''
|
|
121
|
+
: assets.length > 0
|
|
121
122
|
? this.handleAssets(assets.map(({ asset }) => asset), exportAssetsAs)
|
|
122
123
|
: this.handleAssets([hydratedProduct.featuredAsset], exportAssetsAs);
|
|
123
124
|
const productFacets = languages.reduce((acc, lang) => {
|
|
@@ -150,14 +151,23 @@ let ProductExportService = class ProductExportService {
|
|
|
150
151
|
const variantTranslations = variant.translations;
|
|
151
152
|
const variantNameTranslations = this.mapTranslations(variantTranslations, 'name', languages);
|
|
152
153
|
const record = {};
|
|
154
|
+
const convertToHTML = (text) => {
|
|
155
|
+
return text
|
|
156
|
+
.replace(/\n/g, '<br>')
|
|
157
|
+
.replace(/\t/g, ' ')
|
|
158
|
+
.replace(/,\s*'/g, ", '");
|
|
159
|
+
};
|
|
153
160
|
for (const lang of languages) {
|
|
154
|
-
const escapedDescription = descriptionTranslations[lang]
|
|
155
|
-
const escapedName = nameTranslations[lang]
|
|
161
|
+
const escapedDescription = convertToHTML(descriptionTranslations[lang]);
|
|
162
|
+
const escapedName = nameTranslations[lang]
|
|
163
|
+
.replace(/"/g, "'")
|
|
164
|
+
.replace(/\s+/g, ' ')
|
|
165
|
+
.replace(/,\s*'/g, ", '")
|
|
166
|
+
.replace(/'/g, "''");
|
|
156
167
|
record.productId = records.length === 0 ? product.id : '';
|
|
157
168
|
record[`name:${lang}`] = records.length === 0 ? escapedName || '' : '';
|
|
158
169
|
record[`slug:${lang}`] = records.length === 0 ? slugTranslations[lang] || '' : '';
|
|
159
|
-
record[`description:${lang}`] =
|
|
160
|
-
records.length === 0 ? escapedDescription || '' : '';
|
|
170
|
+
record[`description:${lang}`] = records.length === 0 ? escapedDescription || '' : '';
|
|
161
171
|
record[`facets:${lang}`] = records.length === 0 ? productFacets[lang] : '';
|
|
162
172
|
record[`optionGroups:${lang}`] = records.length === 0 ? optionGroupNames[lang] : '';
|
|
163
173
|
record[`optionValues:${lang}`] = variantValues[lang];
|