fix(medusa): getAvailableContext should first check if the inventory service is present (#4293)

* fix(medusa): getAvailableContext should first check if the inventory service is present

* Create clever-seals-share.md
This commit is contained in:
Adrien de Peretti
2023-06-13 18:14:43 +02:00
committed by GitHub
parent 2ebc3da98a
commit 2c0074031b
2 changed files with 9 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
---
"@medusajs/medusa": patch
---
fix(medusa): getAvailableContext should first check if the inventory service is present

View File

@@ -820,6 +820,10 @@ class ProductVariantInventoryService extends TransactionBaseService {
products: (Product | PricedProduct)[],
salesChannelId: string | string[] | undefined
): Promise<(Product | PricedProduct)[]> {
if (!this.inventoryService_) {
return products
}
const variantIds: string[] = products
.flatMap((p) => p.variants.map((v: { id?: string }) => v.id) ?? [])
.filter((v): v is string => !!v)