[object Object]

← back to Designer Wallcoverings

Sweep: fix flushInv fallback (set-per-item before activate) — repaired 1275 already-active stragglers to 2026

c3d80f3db57349fdd5f777cdff49bd28a6027b91 · 2026-06-11 13:03:22 -0700 · SteveStudio2

Files touched

Diff

commit c3d80f3db57349fdd5f777cdff49bd28a6027b91
Author: SteveStudio2 <steve@designerwallcoverings.com>
Date:   Thu Jun 11 13:03:22 2026 -0700

    Sweep: fix flushInv fallback (set-per-item before activate) — repaired 1275 already-active stragglers to 2026
---
 shopify/scripts/active-2026-and-all-channels.js | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/shopify/scripts/active-2026-and-all-channels.js b/shopify/scripts/active-2026-and-all-channels.js
index 1e472a6e..c1841f6b 100644
--- a/shopify/scripts/active-2026-and-all-channels.js
+++ b/shopify/scripts/active-2026-and-all-channels.js
@@ -76,11 +76,16 @@ async function flushInv() {
   const r = await gqlR(M_SET, { input: { reason: 'correction', name: 'available', ignoreCompareQuantity: true, quantities: batch } });
   const ue = r.data?.inventorySetQuantities?.userErrors || [];
   if (!ue.length) { stats.invSet += batch.length; return; }
-  // Some items not stocked at location → activate them individually at 2026.
+  // Batch failed because ≥1 item isn't stocked at the location (atomic batch).
+  // Per item: try set first (works for already-active items); only fall back to
+  // activate when the item genuinely isn't stocked there.
   for (const q of batch) {
+    const sr = await gqlR(M_SET, { input: { reason: 'correction', name: 'available', ignoreCompareQuantity: true, quantities: [q] } });
+    const se = sr.data?.inventorySetQuantities?.userErrors || [];
+    if (!se.length) { stats.invSet++; continue; }
     const ar = await gqlR(M_ACTIVATE, { itemId: q.inventoryItemId, locId: LOCATION_ID, qty: TARGET_QTY });
     const ae = ar.data?.inventoryActivate?.userErrors || [];
-    if (ae.length) { stats.invErrors++; logFail({ inventoryItemId: q.inventoryItemId, ae }); }
+    if (ae.length) { stats.invErrors++; logFail({ inventoryItemId: q.inventoryItemId, ae, se }); }
     else stats.invActivated++;
     await sleep(60);
   }

← 0548262d Add schu-reconcile-pids: backfill shopify_product_id from Sh  ·  back to Designer Wallcoverings  ·  Add fix-broken-rolls.js — guardrailed live-price fixer (dry- 7cc6bdfc →