fix: prioritize ASIN column detection over SKU in processBuyBoxExcel

This commit is contained in:
Christian Vidal Wolf
2026-03-03 14:23:08 +01:00
parent 93c2a699ea
commit 036e7b9a0a
+12 -4
View File
@@ -2577,11 +2577,19 @@ export const processBuyBoxExcel = async (fileOrBuffer: File | ArrayBuffer): Prom
} }
} }
const asinIdx = headers.findIndex(h => { let finalAsinIdx = headers.findIndex(h => {
const s = String(h || '').toUpperCase().trim(); const s = String(h || '').toUpperCase().replace(/[^A-Z]/g, '');
return s === 'ASIN' || s.includes('AMAZON ASIN') || s.includes('CHILD ASIN') || s.includes('IDENTIFIER') || s.includes('PRODUCT ID') || s.includes('SKU'); return s === 'ASIN' || s.includes('AMAZONASIN') || s.includes('CHILDASIN');
}); });
let finalAsinIdx = asinIdx !== -1 ? asinIdx : 1; // Default to Col B if not found
if (finalAsinIdx === -1) {
finalAsinIdx = headers.findIndex(h => {
const s = String(h || '').toUpperCase().replace(/[^A-Z]/g, '');
return s.includes('IDENTIFIER') || s.includes('PRODUCTID') || s.includes('SKU');
});
}
if (finalAsinIdx === -1) finalAsinIdx = 1; // Default to Col B if not found
// Dynamically find the "Issue Type" or "Reason" column // Dynamically find the "Issue Type" or "Reason" column
let reasonIdx = headers.findIndex(h => { let reasonIdx = headers.findIndex(h => {