This commit is contained in:
seb
2026-10-04 21:22:02 +02:00
parent 45369d11da
commit 3ac713732c
12 changed files with 92 additions and 92 deletions

View File

@@ -80,9 +80,9 @@ export async function listExport(googleAuthId, categoryId) {
return store.article.listExport(googleAuthId, categoryId);
}
export async function toggleFather(googleAuthId, sku, options) {
export async function toggleParent(googleAuthId, sku, options) {
const store = await getStore();
return store.article.toggleFather(googleAuthId, sku, options);
return store.article.toggleParent(googleAuthId, sku, options);
}
export async function addChild(googleAuthId, sku, options) {

View File

@@ -138,7 +138,7 @@ export async function listArticles(companyId, { categoryId, limit = 50, offset =
const whereClauses = [
'a.company_id = @companyId',
'a.fatherarticle_id IS NULL',
'a.parentarticle_id IS NULL',
];
if (categoryId != null) {
whereClauses.push('ca.category_id = @categoryId');
@@ -280,9 +280,9 @@ export async function getArticleBySku(companyId, sku) {
brand_pic.thumbw AS brandThumbW,
brand_pic.thumbh AS brandThumbH,
brand_pic.thumbhash AS brandThumbHash,
a.is_father AS isFather,
a.fatherarticle_id AS fatherArticleId,
father.sku AS fatherSku
a.is_parent AS isParent,
a.parentarticle_id AS parentArticleId,
parent.sku AS parentSku
FROM article a
LEFT JOIN articletext at
ON at.article_id = a.id AND at.language_id = @languageId
@@ -297,7 +297,7 @@ export async function getArticleBySku(companyId, sku) {
ORDER BY bp.sort, bp.id
LIMIT 1
)
LEFT JOIN article father ON father.id = a.fatherarticle_id
LEFT JOIN article parent ON parent.id = a.parentarticle_id
WHERE a.sku = @sku AND a.company_id = @companyId`
: `SELECT
a.id,
@@ -319,9 +319,9 @@ export async function getArticleBySku(companyId, sku) {
brand_pic.thumbw AS brandThumbW,
brand_pic.thumbh AS brandThumbH,
brand_pic.thumbhash AS brandThumbHash,
a.is_father AS isFather,
a.fatherarticle_id AS fatherArticleId,
father.sku AS fatherSku
a.is_parent AS isParent,
a.parentarticle_id AS parentArticleId,
parent.sku AS parentSku
FROM article a
LEFT JOIN articletext at
ON at.article_id = a.id AND at.language_id = @languageId
@@ -336,7 +336,7 @@ export async function getArticleBySku(companyId, sku) {
ORDER BY bp.sort ASC, bp.id ASC
) first_brand_pic
LEFT JOIN pic brand_pic ON brand_pic.id = first_brand_pic.pic_id
LEFT JOIN article father ON father.id = a.fatherarticle_id
LEFT JOIN article parent ON parent.id = a.parentarticle_id
WHERE a.sku = @sku AND a.company_id = @companyId`;
const result = await provider.query(sql, {
@@ -396,12 +396,12 @@ export async function getArticleBySku(companyId, sku) {
ORDER BY pr.minmultiplier ASC`,
{ articleId, posCustomerGroupId: company.posCustomerGroupId }
),
row.isFather
row.isParent
? provider.query(
`SELECT
child.id,
child.sku,
child.fathersort,
child.parentsort,
child.track_stock AS trackStock,
child.unitamount,
child.weight,
@@ -413,8 +413,8 @@ export async function getArticleBySku(companyId, sku) {
LEFT JOIN articletext at_child ON at_child.article_id = child.id AND at_child.language_id = @languageId
LEFT JOIN articleattributevalue aav ON aav.article_id = child.id
LEFT JOIN attributevalue av ON av.id = aav.attributevalue_id
WHERE child.fatherarticle_id = @articleId
ORDER BY child.fathersort ASC, child.id ASC`,
WHERE child.parentarticle_id = @articleId
ORDER BY child.parentsort ASC, child.id ASC`,
{ articleId, languageId: company.languageId }
)
: Promise.resolve({ rows: [] }),
@@ -480,12 +480,12 @@ export async function getArticleBySku(companyId, sku) {
thumbHash: p.thumbHash,
})),
eans: eansRes.rows.map((e) => e.ean),
isFather: Boolean(row.isFather),
fatherSku: row.fatherSku ?? null,
isParent: Boolean(row.isParent),
parentSku: row.parentSku ?? null,
variants: variantsRes.rows.map((v) => ({
id: v.id,
sku: v.sku,
sort: v.fathersort,
sort: v.parentsort,
name: v.name ?? '',
slug: v.slug ?? '',
attributeValueId: v.attributeValueId ?? null,