From f71df3f558a614f83d52e3d0ab17cf8ac6e29413 Mon Sep 17 00:00:00 2001 From: pi-bot-01 Date: Sat, 21 Mar 2026 23:06:05 -0700 Subject: [PATCH] Fix SKU conversion: rootSV base + '01', not base + variant rootSV '0419363_1' was producing '4193631' (wrong) Now correctly produces '41936301' (confirmed by user) The '_N' suffix is a variant/image index, not part of the SKU. Pattern: strip leading zero from base, append '01'. --- disco.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/disco.py b/disco.py index 71f1fcc..849c5c4 100644 --- a/disco.py +++ b/disco.py @@ -80,13 +80,15 @@ def extract_products_from_har(har_path: str) -> list[dict]: def rootsv_to_sku(rootsv: str) -> str: - """Convert rootSV like '0419363_1' to SKU like '41936301'.""" + """Convert rootSV like '0419363_1' to SKU like '41936301'. + + The rootSV base (minus leading zero) + '01' gives the DG item number. + The '_N' suffix is a variant/image index, not part of the SKU. + """ if not rootsv: return "" - parts = rootsv.split("_") - base = parts[0].lstrip("0") - suffix = parts[1] if len(parts) > 1 else "" - return base + suffix + base = rootsv.split("_")[0].lstrip("0") + return base + "01" def build_product_url(upc: str) -> str: