From 0fdffb864f9750998d7448006bb2a194f9664a0f Mon Sep 17 00:00:00 2001 From: seb Date: Fri, 30 Oct 2026 06:43:49 +0100 Subject: [PATCH] u --- src/providers/mssql/queries/category.js | 2 -- src/providers/sqlite3/queries/category.js | 1 - test/category.test.js | 16 ++++++++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/providers/mssql/queries/category.js b/src/providers/mssql/queries/category.js index 36e16cf..e45c93f 100644 --- a/src/providers/mssql/queries/category.js +++ b/src/providers/mssql/queries/category.js @@ -64,7 +64,6 @@ FROM categoryarticle ca INNER JOIN article a ON a.id = ca.article_id ${ARTICLE_LIST_JOINS} WHERE ca.category_id = @categoryId - AND a.parentarticle_id IS NULL ORDER BY a.id `; @@ -80,7 +79,6 @@ INNER JOIN warehouse w ON w.id = aws.warehouse_id INNER JOIN categoryarticle ca ON ca.article_id = aws.article_id INNER JOIN article a ON a.id = ca.article_id WHERE ca.category_id = @categoryId - AND a.parentarticle_id IS NULL ORDER BY w.sort ASC, w.name ASC, aws.id ASC `; diff --git a/src/providers/sqlite3/queries/category.js b/src/providers/sqlite3/queries/category.js index 0640b97..90f9047 100644 --- a/src/providers/sqlite3/queries/category.js +++ b/src/providers/sqlite3/queries/category.js @@ -86,7 +86,6 @@ FROM categoryarticle ca INNER JOIN article a ON a.id = ca.article_id ${ARTICLE_LIST_JOINS} WHERE ca.category_id = @categoryId - AND a.parentarticle_id IS NULL ORDER BY a.id `; diff --git a/test/category.test.js b/test/category.test.js index 1e157ba..d509cd5 100644 --- a/test/category.test.js +++ b/test/category.test.js @@ -105,6 +105,22 @@ describe('store.category', () => { assert.ok(listWithImg[0].smallThumbBinary.length > 0); }); + it('includes child articles (variants) in the category', async () => { + const cat = await create('Variants Cat'); + const attr = await store.attributename.create(tenant.googleAuthId, { name: 'Größe' }); + const parent = await createArticle(store, tenant, { parentId: cat.id, name: 'Shirt Parent' }); + await store.article.toggleParent(tenant.googleAuthId, parent.sku, { isParent: true, attributeNameId: attr.id }); + const child = await store.article.addChild(tenant.googleAuthId, parent.sku, { value: 'XL' }); + + const list = await store.category.getCategoryArticles(tenant.googleAuthId, cat.id); + const skus = list.map((a) => a.sku); + assert.ok(skus.includes(parent.sku)); + assert.ok(skus.includes(child.article.sku)); + const childItem = list.find((a) => a.sku === child.article.sku); + assert.equal(childItem.parentArticleId, parent.id); + assert.equal(childItem.parentSku, parent.sku); + }); + it('rejects a category of another company', async () => { await assert.rejects( () => store.category.getCategoryArticles(tenant.googleAuthId, other.rootCategoryId),