@haus-tech/product-import-export-plugin 3.0.6 → 3.0.7
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.
|
@@ -35,7 +35,6 @@ export declare class ProductImporter {
|
|
|
35
35
|
private doParseAndImport;
|
|
36
36
|
private getRequestContext;
|
|
37
37
|
importProducts(ctx: RequestContext, rows: ParsedProductWithId[], updatingStrategy: UpdatingStrategy, onProgress: OnProgressFn): Promise<string[]>;
|
|
38
|
-
private getFacetValueIds;
|
|
39
38
|
private processCustomFieldValues;
|
|
40
39
|
/**
|
|
41
40
|
* Attempts to match a TaxCategory entity against the name supplied in the import table. If no matches
|
|
@@ -413,10 +413,10 @@ let ProductImporter = class ProductImporter {
|
|
|
413
413
|
if (createVariantAssets.errors.length) {
|
|
414
414
|
errors = errors.concat(createVariantAssets.errors);
|
|
415
415
|
}
|
|
416
|
-
let facetValueIds = []
|
|
417
|
-
if (0 < variant.facets.length) {
|
|
418
|
-
|
|
419
|
-
}
|
|
416
|
+
// let facetValueIds: ID[] = []
|
|
417
|
+
// if (0 < variant.facets.length) {
|
|
418
|
+
// facetValueIds = await this.getFacetValueIds(ctx, variant.facets, languageCode)
|
|
419
|
+
// }
|
|
420
420
|
const variantCustomFields = await this.processCustomFieldValues(variantMainTranslation.customFields, this.configService.customFields.ProductVariant, ctx);
|
|
421
421
|
const optionIds = variantMainTranslation.optionValues.map((v, index) => optionsMap[`${index}_${v}`]);
|
|
422
422
|
const existingVariant = await this.connection.getRepository(ctx, core_1.ProductVariant).findOne({
|
|
@@ -504,64 +504,79 @@ let ProductImporter = class ProductImporter {
|
|
|
504
504
|
}
|
|
505
505
|
return errors;
|
|
506
506
|
}
|
|
507
|
-
async getFacetValueIds(
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
507
|
+
// private async getFacetValueIds(
|
|
508
|
+
// ctx: RequestContext,
|
|
509
|
+
// facets: ParsedFacet[],
|
|
510
|
+
// languageCode: LanguageCode,
|
|
511
|
+
// ): Promise<ID[]> {
|
|
512
|
+
// const facetValueIds: ID[] = []
|
|
513
|
+
// for (const item of facets) {
|
|
514
|
+
// const itemMainTranslation = this.getTranslationByCodeOrFirst(item.translations, languageCode)
|
|
515
|
+
// const facetName = itemMainTranslation.facet
|
|
516
|
+
// const valueName = itemMainTranslation.value
|
|
517
|
+
// let facetEntity: Facet
|
|
518
|
+
// const cachedFacet = this.facetMap.get(facetName)
|
|
519
|
+
// if (cachedFacet?.code === 'kategorier') {
|
|
520
|
+
// console.log('cachedFacet', cachedFacet)
|
|
521
|
+
// }
|
|
522
|
+
// if (cachedFacet) {
|
|
523
|
+
// facetEntity = cachedFacet
|
|
524
|
+
// } else {
|
|
525
|
+
// const existing = await this.facetService.findByCode(
|
|
526
|
+
// ctx,
|
|
527
|
+
// normalizeString(facetName, '-', languageCode),
|
|
528
|
+
// languageCode,
|
|
529
|
+
// )
|
|
530
|
+
// if (existing) {
|
|
531
|
+
// if (existing?.code === 'kategorier') {
|
|
532
|
+
// console.log('existingFacet', existing)
|
|
533
|
+
// }
|
|
534
|
+
// facetEntity = existing
|
|
535
|
+
// } else {
|
|
536
|
+
// facetEntity = await this.facetService.create(ctx, {
|
|
537
|
+
// isPrivate: false,
|
|
538
|
+
// code: normalizeString(facetName, '-', languageCode),
|
|
539
|
+
// translations: item.translations.map((translation) => {
|
|
540
|
+
// return {
|
|
541
|
+
// languageCode: translation.languageCode,
|
|
542
|
+
// name: translation.facet,
|
|
543
|
+
// }
|
|
544
|
+
// }),
|
|
545
|
+
// })
|
|
546
|
+
// }
|
|
547
|
+
// this.facetMap.set(facetName, facetEntity)
|
|
548
|
+
// }
|
|
549
|
+
// let facetValueEntity: FacetValue
|
|
550
|
+
// const facetValueMapKey = `${facetName}:${valueName}`
|
|
551
|
+
// const cachedFacetValue = this.facetValueMap.get(facetValueMapKey)
|
|
552
|
+
// if (cachedFacetValue) {
|
|
553
|
+
// facetValueEntity = cachedFacetValue
|
|
554
|
+
// if (cachedFacetValue?.code === 'duschhoerna') {
|
|
555
|
+
// console.log('cachedFacetValue', cachedFacetValue)
|
|
556
|
+
// }
|
|
557
|
+
// } else {
|
|
558
|
+
// const existing = facetEntity.values.find(
|
|
559
|
+
// (v) => normalizeString(v.name, '-') === normalizeString(valueName, '-', languageCode),
|
|
560
|
+
// )
|
|
561
|
+
// if (existing) {
|
|
562
|
+
// facetValueEntity = existing
|
|
563
|
+
// } else {
|
|
564
|
+
// facetValueEntity = await this.facetValueService.create(ctx, facetEntity, {
|
|
565
|
+
// code: normalizeString(valueName, '-', languageCode),
|
|
566
|
+
// translations: item.translations.map((translation) => {
|
|
567
|
+
// return {
|
|
568
|
+
// languageCode: translation.languageCode,
|
|
569
|
+
// name: translation.value,
|
|
570
|
+
// }
|
|
571
|
+
// }),
|
|
572
|
+
// })
|
|
573
|
+
// }
|
|
574
|
+
// this.facetValueMap.set(facetValueMapKey, facetValueEntity)
|
|
575
|
+
// }
|
|
576
|
+
// facetValueIds.push(facetValueEntity.id)
|
|
577
|
+
// }
|
|
578
|
+
// return facetValueIds
|
|
579
|
+
// }
|
|
565
580
|
async processCustomFieldValues(customFields, config, ctx) {
|
|
566
581
|
function parseBoolean(input) {
|
|
567
582
|
if (input == null) {
|
|
@@ -252,7 +252,7 @@ let ExtendedFastImporterService = class ExtendedFastImporterService {
|
|
|
252
252
|
const facetValueExists = await this.connection
|
|
253
253
|
.getRepository(this.importCtx, core_1.FacetValue)
|
|
254
254
|
.findOne({
|
|
255
|
-
where: { code: input.code },
|
|
255
|
+
where: { code: input.code, facet: { id: input.facetId } },
|
|
256
256
|
relations: ['channels', 'translations'],
|
|
257
257
|
});
|
|
258
258
|
if (facetValueExists) {
|