@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
- facetValueIds = await this.getFacetValueIds(ctx, variant.facets, languageCode);
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(ctx, facets, languageCode) {
508
- const facetValueIds = [];
509
- for (const item of facets) {
510
- const itemMainTranslation = this.getTranslationByCodeOrFirst(item.translations, languageCode);
511
- const facetName = itemMainTranslation.facet;
512
- const valueName = itemMainTranslation.value;
513
- let facetEntity;
514
- const cachedFacet = this.facetMap.get(facetName);
515
- if (cachedFacet) {
516
- facetEntity = cachedFacet;
517
- }
518
- else {
519
- const existing = await this.facetService.findByCode(ctx, (0, normalize_string_1.normalizeString)(facetName, '-', languageCode), languageCode);
520
- if (existing) {
521
- facetEntity = existing;
522
- }
523
- else {
524
- facetEntity = await this.facetService.create(ctx, {
525
- isPrivate: false,
526
- code: (0, normalize_string_1.normalizeString)(facetName, '-', languageCode),
527
- translations: item.translations.map((translation) => {
528
- return {
529
- languageCode: translation.languageCode,
530
- name: translation.facet,
531
- };
532
- }),
533
- });
534
- }
535
- this.facetMap.set(facetName, facetEntity);
536
- }
537
- let facetValueEntity;
538
- const facetValueMapKey = `${facetName}:${valueName}`;
539
- const cachedFacetValue = this.facetValueMap.get(facetValueMapKey);
540
- if (cachedFacetValue) {
541
- facetValueEntity = cachedFacetValue;
542
- }
543
- else {
544
- const existing = facetEntity.values.find((v) => (0, normalize_string_1.normalizeString)(v.name, '-') === (0, normalize_string_1.normalizeString)(valueName, '-', languageCode));
545
- if (existing) {
546
- facetValueEntity = existing;
547
- }
548
- else {
549
- facetValueEntity = await this.facetValueService.create(ctx, facetEntity, {
550
- code: (0, normalize_string_1.normalizeString)(valueName, '-', languageCode),
551
- translations: item.translations.map((translation) => {
552
- return {
553
- languageCode: translation.languageCode,
554
- name: translation.value,
555
- };
556
- }),
557
- });
558
- }
559
- this.facetValueMap.set(facetValueMapKey, facetValueEntity);
560
- }
561
- facetValueIds.push(facetValueEntity.id);
562
- }
563
- return facetValueIds;
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haus-tech/product-import-export-plugin",
3
- "version": "3.0.6",
3
+ "version": "3.0.7",
4
4
  "description": "A Vendure plugin for importing and exporting products using a CSV file",
5
5
  "author": "Haus Tech",
6
6
  "repository": {