Add categoryIds to article.listSearchIndex response

This commit is contained in:
seb
2026-08-03 22:33:46 +02:00
parent 84bb561031
commit c8b1a73b62
3 changed files with 12 additions and 2 deletions

View File

@@ -187,7 +187,14 @@ SELECT
WHERE ae.article_id = a.id
ORDER BY ae.ean
FOR JSON PATH
) AS eansJson
) AS eansJson,
(
SELECT ca2.category_id
FROM categoryarticle ca2
WHERE ca2.article_id = a.id
ORDER BY ca2.category_id
FOR JSON PATH
) AS categoryIdsJson
FROM article a
LEFT JOIN articletext at
ON at.article_id = a.id AND at.language_id = @languageId

View File

@@ -18,6 +18,9 @@ export default function listSearchIndex(pool) {
sku: row.sku,
name: row.name,
eans: row.eansJson ? JSON.parse(row.eansJson).map((r) => r.ean) : [],
categoryIds: row.categoryIdsJson
? JSON.parse(row.categoryIdsJson).map((r) => r.category_id)
: [],
}));
};
}