Remove SKU deletion

This commit is contained in:
Dominic Ferrando
2026-07-17 16:03:43 -04:00
parent d07fe9f7ed
commit 2397889a52
-21
View File
@@ -145,27 +145,6 @@ export class ProductSyncer {
); );
} }
} }
// Remove webflow SKUs whose color+size no longer corresponds to any current printful variant.
const currentPKeys = new Set<string>(
pMetaProduct.entries.flatMap(({ colorGroup, product: pProduct }) =>
pProduct.sync_variants.map((pVariant) => `${colorGroup ?? pVariant.color}::${pVariant.size}`)
)
);
const orphanedWSkus = wProduct.skus.filter((existingWSku) =>
!currentPKeys.has(`${existingWSku.fieldData["sku-values"]?.["color"]}::${existingWSku.fieldData["sku-values"]?.["size"]}`)
);
for (const orphanedWSku of orphanedWSkus) {
this.log.info(
{
wSkuId: orphanedWSku.id,
color: orphanedWSku.fieldData["sku-values"]?.["color"],
size: orphanedWSku.fieldData["sku-values"]?.["size"],
},
"removing webflow SKU no longer present in printful",
);
await this.Webflow.Products.Skus.remove(orphanedWSku.id);
}
} else { } else {
this.log.info("existing webflow product not found, creating it"); this.log.info("existing webflow product not found, creating it");