@haus-tech/product-import-export-plugin 3.0.0 → 3.0.1
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.
|
@@ -147,7 +147,7 @@ ProductImportExportPlugin = ProductImportExportPlugin_1 = __decorate([
|
|
|
147
147
|
});
|
|
148
148
|
return config;
|
|
149
149
|
},
|
|
150
|
-
compatibility: '^3.0.0',
|
|
150
|
+
compatibility: '^2.0.0 || ^3.0.0',
|
|
151
151
|
})
|
|
152
152
|
], ProductImportExportPlugin);
|
|
153
153
|
exports.ProductImportExportPlugin = ProductImportExportPlugin;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { ConfigService, ChannelService, FacetService, FacetValueService, TaxCategoryService, ID, ImportProgress, LanguageCode, RequestContext, OnProgressFn, ParsedFacet, ProductService, TransactionalConnection, TranslatableSaver, AssetService, Asset, ProductOptionGroupService } from '@vendure/core';
|
|
2
|
+
import { ConfigService, ChannelService, FacetService, FacetValueService, TaxCategoryService, ID, ImportProgress, LanguageCode, RequestContext, OnProgressFn, ParsedFacet, ProductService, Product, TransactionalConnection, TranslatableSaver, AssetService, Asset, ProductOptionGroupService } from '@vendure/core';
|
|
3
3
|
import { Stream } from 'stream';
|
|
4
4
|
import { Observable } from 'rxjs';
|
|
5
5
|
import { ExtendedFastImporterService } from '../../services/extended-fast-importer.service';
|
|
@@ -43,5 +43,6 @@ export declare class ProductImporter {
|
|
|
43
43
|
*/
|
|
44
44
|
private getMatchingTaxCategoryId;
|
|
45
45
|
private getTranslationByCodeOrFirst;
|
|
46
|
+
getProduct(ctx: RequestContext, id: ID): Promise<Product>;
|
|
46
47
|
createFacetAndValue(facet: ParsedFacet, facetCode: string, valueCode: string): Promise<ID>;
|
|
47
48
|
}
|
|
@@ -282,21 +282,8 @@ let ProductImporter = class ProductImporter {
|
|
|
282
282
|
checkExistingProduct = { id: foundVariants[0].productId };
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
|
-
const existingProduct = checkExistingProduct
|
|
286
|
-
? await this.
|
|
287
|
-
where: { id: checkExistingProduct?.id },
|
|
288
|
-
withDeleted: true,
|
|
289
|
-
relations: [
|
|
290
|
-
'facetValues',
|
|
291
|
-
'facetValues.facet',
|
|
292
|
-
'optionGroups',
|
|
293
|
-
'optionGroups.options',
|
|
294
|
-
'variants',
|
|
295
|
-
'variants.facetValues',
|
|
296
|
-
'assets',
|
|
297
|
-
'featuredAsset',
|
|
298
|
-
],
|
|
299
|
-
})
|
|
285
|
+
const existingProduct = checkExistingProduct?.id
|
|
286
|
+
? (await this.getProduct(ctx, checkExistingProduct.id))
|
|
300
287
|
: undefined;
|
|
301
288
|
try {
|
|
302
289
|
if (existingProduct?.deletedAt) {
|
|
@@ -494,18 +481,7 @@ let ProductImporter = class ProductImporter {
|
|
|
494
481
|
}
|
|
495
482
|
}
|
|
496
483
|
if (existingProduct) {
|
|
497
|
-
const productAfterUpdate = (await this.
|
|
498
|
-
where: { id: createdProductId },
|
|
499
|
-
relations: [
|
|
500
|
-
'facetValues',
|
|
501
|
-
'facetValues.facet',
|
|
502
|
-
'optionGroups',
|
|
503
|
-
'optionGroups.options',
|
|
504
|
-
'variants',
|
|
505
|
-
'variants.facetValues',
|
|
506
|
-
'assets',
|
|
507
|
-
],
|
|
508
|
-
})); // We know that the product exists, so we can safely cast it to Product
|
|
484
|
+
const productAfterUpdate = (await this.getProduct(ctx, createdProductId)); // We know that the product exists, so we can safely cast it to Product
|
|
509
485
|
const existingProductHash = (0, crypto_1.createHash)('md5')
|
|
510
486
|
.update(JSON.stringify((0, remove_update_at_fields_1.removeUpdatedAtFields)(existingProduct)))
|
|
511
487
|
.digest('hex');
|
|
@@ -702,6 +678,22 @@ let ProductImporter = class ProductImporter {
|
|
|
702
678
|
}
|
|
703
679
|
return translation;
|
|
704
680
|
}
|
|
681
|
+
async getProduct(ctx, id) {
|
|
682
|
+
const product = (await this.connection.getRepository(ctx, core_1.Product).findOne({
|
|
683
|
+
where: { id: id },
|
|
684
|
+
relations: [
|
|
685
|
+
'facetValues',
|
|
686
|
+
'facetValues.facet',
|
|
687
|
+
'optionGroups',
|
|
688
|
+
'optionGroups.options',
|
|
689
|
+
'variants',
|
|
690
|
+
'variants.facetValues',
|
|
691
|
+
'assets',
|
|
692
|
+
'featuredAsset',
|
|
693
|
+
],
|
|
694
|
+
}));
|
|
695
|
+
return product;
|
|
696
|
+
}
|
|
705
697
|
async createFacetAndValue(facet, facetCode, valueCode) {
|
|
706
698
|
const facetId = await this.fastImporter.createFacet({
|
|
707
699
|
code: facetCode,
|