fix(medusa): In product isolation, throw if product not found (#5224)
**What** Throw not found error if product does not exists
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/medusa": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(medusa): In product isolation, throw if product not found
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import { PricingService, ProductService } from "../../../../services"
|
import { PricingService, ProductService } from "../../../../services"
|
||||||
import IsolateProductDomainFeatureFlag from "../../../../loaders/feature-flags/isolate-product-domain"
|
import IsolateProductDomainFeatureFlag from "../../../../loaders/feature-flags/isolate-product-domain"
|
||||||
import { defaultAdminProductRemoteQueryObject } from "./index"
|
import { defaultAdminProductRemoteQueryObject } from "./index"
|
||||||
|
import { MedusaError } from "@medusajs/utils"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @oas [get] /admin/products/{id}
|
* @oas [get] /admin/products/{id}
|
||||||
@@ -100,6 +101,13 @@ async function getProductWithIsolatedProductModule(req, id, retrieveConfig) {
|
|||||||
|
|
||||||
const [product] = await remoteQuery(query)
|
const [product] = await remoteQuery(query)
|
||||||
|
|
||||||
|
if (!product) {
|
||||||
|
throw new MedusaError(
|
||||||
|
MedusaError.Types.NOT_FOUND,
|
||||||
|
`Product with id: ${id} not found`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
product.profile_id = product.profile?.id
|
product.profile_id = product.profile?.id
|
||||||
|
|
||||||
return product
|
return product
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { PriceSelectionParams } from "../../../../types/price-selection"
|
|||||||
import { cleanResponseData } from "../../../../utils"
|
import { cleanResponseData } from "../../../../utils"
|
||||||
import IsolateProductDomain from "../../../../loaders/feature-flags/isolate-product-domain"
|
import IsolateProductDomain from "../../../../loaders/feature-flags/isolate-product-domain"
|
||||||
import { defaultStoreProductRemoteQueryObject } from "./index"
|
import { defaultStoreProductRemoteQueryObject } from "./index"
|
||||||
|
import { MedusaError } from "@medusajs/utils"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @oas [get] /store/products/{id}
|
* @oas [get] /store/products/{id}
|
||||||
@@ -176,6 +177,13 @@ async function getProductWithIsolatedProductModule(req, id: string) {
|
|||||||
|
|
||||||
const [product] = await remoteQuery(query)
|
const [product] = await remoteQuery(query)
|
||||||
|
|
||||||
|
if (!product) {
|
||||||
|
throw new MedusaError(
|
||||||
|
MedusaError.Types.NOT_FOUND,
|
||||||
|
`Product with id: ${id} not found`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
product.profile_id = product.profile?.id
|
product.profile_id = product.profile?.id
|
||||||
|
|
||||||
return product
|
return product
|
||||||
|
|||||||
Reference in New Issue
Block a user