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

View File

@@ -341,12 +341,18 @@ class ProductImportStrategy extends AbstractBatchJobStrategy {
}
if (!channel) {
channel = (await salesChannelServiceTx.retrieveByName(input.name, {
select: ["id"],
})) as SalesChannel
try {
channel = (await salesChannelServiceTx.retrieveByName(input.name, {
select: ["id"],
})) as SalesChannel
} catch (e) {
// noop
}
}
salesChannels.push(channel)
if (channel) {
salesChannels.push(channel)
}
}
return salesChannels
@@ -382,7 +388,7 @@ class ProductImportStrategy extends AbstractBatchJobStrategy {
) as unknown as CreateProductInput
try {
if (isSalesChannelsFeatureOn) {
if (isSalesChannelsFeatureOn && productOp["product.sales_channels"]) {
productData["sales_channels"] = await this.processSalesChannels(
productOp["product.sales_channels"] as Pick<
SalesChannel,