This commit is contained in:
seb
2026-10-12 03:10:35 +02:00
parent 15a17574c3
commit a2e446af47
17 changed files with 647 additions and 335 deletions

View File

@@ -72,12 +72,12 @@ export async function importPfand({
// 1. Identify parent articles and map their Pfand values so child variants can inherit
const parentPfandMap = new Map();
for (const a of includedArticles) {
const sku = cleanValue(a.cArtNr);
const isParent = a.nIstVater === '1' || (sku && parentSkus.has(sku));
const sku = cleanValue(a.sku ?? a.cArtNr);
const isParent = a.is_parent === '1' || a.nIstVater === '1' || (sku && parentSkus.has(sku));
if (isParent) {
const val = extractPfandValue(a.attributes);
if (val != null) {
parentPfandMap.set(String(a.kArtikel), val);
parentPfandMap.set(String(a.id ?? a.kArtikel), val);
}
}
}
@@ -85,19 +85,20 @@ export async function importPfand({
// 2. Discover target articles (purchasable standalone or variant items) and their Pfand values
const articleTargets = [];
for (const a of includedArticles) {
const sku = cleanValue(a.cArtNr);
const sku = cleanValue(a.sku ?? a.cArtNr);
if (!sku) continue;
const isParent = a.nIstVater === '1' || parentSkus.has(sku);
const isParent = a.is_parent === '1' || a.nIstVater === '1' || parentSkus.has(sku);
if (isParent) {
// Parent articles cannot have options in Dash
continue;
}
let pfandVal = extractPfandValue(a.attributes);
if (pfandVal == null && a.kVaterArtikel && a.kVaterArtikel !== '0') {
if (parentPfandMap.has(String(a.kVaterArtikel))) {
pfandVal = parentPfandMap.get(String(a.kVaterArtikel));
const parentId = cleanValue(a.parentid ?? a.kVaterArtikel);
if (pfandVal == null && parentId && parentId !== '0') {
if (parentPfandMap.has(parentId)) {
pfandVal = parentPfandMap.get(parentId);
}
}