u
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user