This commit is contained in:
seb
2026-10-30 06:43:49 +01:00
parent 64050dffaf
commit 0fdffb864f
3 changed files with 16 additions and 3 deletions

View File

@@ -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
`;

View File

@@ -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
`;

View File

@@ -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),