fix(medusa): Check for Sales Channel on product import (#2202)

This commit is contained in:
Frane Polić
2022-09-14 09:53:23 +02:00
committed by GitHub
parent f2eb942b41
commit 992ef733f4
@@ -341,12 +341,18 @@ class ProductImportStrategy extends AbstractBatchJobStrategy {
} }
if (!channel) { if (!channel) {
channel = (await salesChannelServiceTx.retrieveByName(input.name, { try {
select: ["id"], channel = (await salesChannelServiceTx.retrieveByName(input.name, {
})) as SalesChannel select: ["id"],
})) as SalesChannel
} catch (e) {
// noop
}
} }
salesChannels.push(channel) if (channel) {
salesChannels.push(channel)
}
} }
return salesChannels return salesChannels
@@ -382,7 +388,7 @@ class ProductImportStrategy extends AbstractBatchJobStrategy {
) as unknown as CreateProductInput ) as unknown as CreateProductInput
try { try {
if (isSalesChannelsFeatureOn) { if (isSalesChannelsFeatureOn && productOp["product.sales_channels"]) {
productData["sales_channels"] = await this.processSalesChannels( productData["sales_channels"] = await this.processSalesChannels(
productOp["product.sales_channels"] as Pick< productOp["product.sales_channels"] as Pick<
SalesChannel, SalesChannel,