fix(product): Correctly fetch category descendants by handle (#13579)
This PR fixes the issue #13518 where product category descendants were not retrieved when filtering by handle with the include_descendants_tree flag. The handle filter was not being correctly removed before the descendant tree query was executed.
This commit is contained in:
1 parent
513b352da3
commit
a501364b2d
3 files changed
+33
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/product": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(product): Correctly fetch category descendants by handle
|
||||||
@@ -598,6 +598,33 @@ medusaIntegrationTestRunner({
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("should filter by handle and retrieve descendants tree", async () => {
|
||||||
|
const response = await api.get(
|
||||||
|
`/admin/product-categories?handle=${productCategoryParent.handle}&include_descendants_tree=true`,
|
||||||
|
adminHeaders
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(response.status).toEqual(200)
|
||||||
|
expect(response.data.product_categories).toEqual([
|
||||||
|
expect.objectContaining({
|
||||||
|
id: productCategoryParent.id,
|
||||||
|
handle: productCategoryParent.handle,
|
||||||
|
category_children: [
|
||||||
|
expect.objectContaining({
|
||||||
|
id: productCategory.id,
|
||||||
|
handle: productCategory.handle,
|
||||||
|
category_children: [
|
||||||
|
expect.objectContaining({
|
||||||
|
id: productCategoryChild.id,
|
||||||
|
handle: productCategoryChild.handle,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
})
|
||||||
|
|
||||||
it("filters based on free text on name and handle columns", async () => {
|
it("filters based on free text on name and handle columns", async () => {
|
||||||
const response = await api.get(
|
const response = await api.get(
|
||||||
`/admin/product-categories?q=men&limit=1`,
|
`/admin/product-categories?q=men&limit=1`,
|
||||||
|
|||||||
@@ -182,6 +182,7 @@ export class ProductCategoryRepository extends DALUtils.MikroOrmBaseTreeReposito
|
|||||||
} as MikroOptions<any>
|
} as MikroOptions<any>
|
||||||
|
|
||||||
delete where.id
|
delete where.id
|
||||||
|
delete where.handle
|
||||||
delete where.mpath
|
delete where.mpath
|
||||||
delete where.parent_category_id
|
delete where.parent_category_id
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user