feat(medusa): List (service + controller) product categories #3004 (#3023)

**What:**

Introduces a store endpoint to retrieve a list of product categories

**Why:**

This is part of a greater goal of allowing products to be added to multiple categories.

**How:**

- Creates an endpoint in store routes

RESOLVES CORE-968
This commit is contained in:
Riqwan Thamir
2023-01-16 19:20:42 +00:00
committed by GitHub
parent c49747b3ad
commit 7d4b8b9cc5
10 changed files with 358 additions and 57 deletions
@@ -27,10 +27,26 @@ describe("Product Categories", () => {
let productCategoryRepository
beforeEach(async () => {
a1 = await simpleProductCategoryFactory(dbConnection, { name: 'a1', handle: 'a1' })
a11 = await simpleProductCategoryFactory(dbConnection, { name: 'a11', handle: 'a11', parent_category: a1 })
a111 = await simpleProductCategoryFactory(dbConnection, { name: 'a111', handle: 'a111', parent_category: a11 })
a12 = await simpleProductCategoryFactory(dbConnection, { name: 'a12', handle: 'a12', parent_category: a1 })
a1 = await simpleProductCategoryFactory(dbConnection, {
name: 'a1',
is_active: true
})
a11 = await simpleProductCategoryFactory(dbConnection, {
name: 'a11',
parent_category: a1,
is_active: true
})
a111 = await simpleProductCategoryFactory(dbConnection, {
name: 'a111',
parent_category: a11,
is_active: true,
is_internal: true
})
a12 = await simpleProductCategoryFactory(dbConnection, {
name: 'a12',
parent_category: a1,
is_active: false
})
productCategoryRepository = dbConnection.manager.getCustomRepository(ProductCategoryRepository)
})
@@ -184,7 +200,7 @@ describe("Product Categories", () => {
const [ categories, count ] = await productCategoryRepository.getFreeTextSearchResultsAndCount(
{
where: { id: a11.id },
relations: ['parent_category', 'category_children']
relations: ['parent_category', 'category_children'],
},
)