u
This commit is contained in:
@@ -97,14 +97,19 @@ function scheduleRebuild() {
|
||||
*/
|
||||
function toIndexRecord(article, categoryId) {
|
||||
const eans = article.eans ?? article.eanCodes ?? article.ean ?? null;
|
||||
const childCount = Number(article.childCount) || 0;
|
||||
const price = article.price ?? article.net ?? article.vknetto ?? null;
|
||||
return {
|
||||
...article,
|
||||
id: article.id,
|
||||
sku: article.sku,
|
||||
name: article.name,
|
||||
price,
|
||||
net: article.net ?? price,
|
||||
eans: Array.isArray(eans) ? eans.filter(Boolean) : eans ? [eans] : [],
|
||||
categories: categoryId != null ? String(categoryId) : null,
|
||||
isParent: Boolean(article.isParent ?? article.is_parent),
|
||||
isParent: Boolean(article.isParent ?? article.is_parent ?? (childCount > 0)),
|
||||
childCount,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -135,7 +140,20 @@ export function buildArticleIndex(views) {
|
||||
ids.add(String(categoryId));
|
||||
existing.categories = Array.from(ids).join(',');
|
||||
}
|
||||
existing.isParent = Boolean(existing.isParent || (article.isParent ?? article.is_parent));
|
||||
const childCount = Number(article.childCount) || 0;
|
||||
if (childCount > (Number(existing.childCount) || 0)) {
|
||||
existing.childCount = childCount;
|
||||
}
|
||||
existing.isParent = Boolean(
|
||||
existing.isParent ||
|
||||
(article.isParent ?? article.is_parent) ||
|
||||
(childCount > 0)
|
||||
);
|
||||
if (existing.price == null && (article.price != null || article.net != null)) {
|
||||
const p = article.price ?? article.net ?? article.vknetto;
|
||||
existing.price = p;
|
||||
existing.net = article.net ?? p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user