fix: SKU map tool

This commit is contained in:
Brennan Wilkes (Text Groove) 2026-01-31 18:26:52 -08:00
parent af6d268560
commit d291cc1492

View file

@ -37,11 +37,12 @@ let prunedAuto = 0;
let prunedDup = 0; let prunedDup = 0;
const seen = new Set(); // dedupe after normalization const seen = new Set(); // dedupe after normalization
const nextLinks = []; const nextLinks = [];
for (const x of Array.isArray(linksData.links) ? linksData.links : []) { for (const x of Array.isArray(linksData.links) ? linksData.links : []) {
const a = normalizeImplicitSkuKey(x?.fromSku); const a = normalizeImplicitSkuKey(x?.fromSku);
const b = normalizeImplicitSkuKey(x?.toSku); const b = normalizeImplicitSkuKey(x?.toSku);
if (!a || !b) { if (!a || !b) {
prunedMissing++; prunedMissing++;
continue; continue;
@ -67,7 +68,12 @@ for (const x of Array.isArray(linksData.links) ? linksData.links : []) {
} }
seen.add(key); seen.add(key);
nextLinks.push({ fromSku: a, toSku: b }); // preserve datestamps/metadata; just normalize the SKUs
nextLinks.push({
...x,
fromSku: a,
toSku: b,
});
} }
linksData.links = nextLinks; linksData.links = nextLinks;