[object Object]

← back to Koroseal Goodrich Audit

auto-save: 2026-07-15T18:39:06 (2 files) — spec_fix.sh spec_fix_targets.json

788d2feac3d71358efc701bf314021ea0dba32bd · 2026-07-15 18:39:11 -0700 · Steve Abrams

Files touched

Diff

commit 788d2feac3d71358efc701bf314021ea0dba32bd
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Wed Jul 15 18:39:11 2026 -0700

    auto-save: 2026-07-15T18:39:06 (2 files) — spec_fix.sh spec_fix_targets.json
---
 spec_fix.sh           | 39 +++++++++++++++++++++++++++++++++++++++
 spec_fix_targets.json |  1 +
 2 files changed, 40 insertions(+)

diff --git a/spec_fix.sh b/spec_fix.sh
new file mode 100644
index 0000000..60ca804
--- /dev/null
+++ b/spec_fix.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+# FIX 5 false-positive spec matches: delete wrongly-written custom specs; re-write from correct prefix-series.
+set -uo pipefail
+TOKEN="$(grep '^SHOPIFY_ADMIN_TOKEN=' ~/Projects/secrets-manager/.env | cut -d= -f2)"
+BASE="https://designer-laboratory-sandbox.myshopify.com/admin/api/2024-10"; H="X-Shopify-Access-Token: $TOKEN"
+SPECKEYS="material backing pattern_match fire_rating roll_width horizontal_repeat vertical_repeat designer"
+# pid|correct-series (empty = leave deleted/empty for review)
+TARGETS="7584945700915|grande
+7585016119347|
+7519958728755|
+7584894877747|coney
+7584918503475|niwa"
+mk(){ case "$1" in material) echo multi_line_text_field;; *) echo single_line_text_field;; esac; }
+label_for(){ case "$1" in material) echo Material;; backing) echo Backing;; pattern_match) echo "Pattern Match";; fire_rating) echo "Fire Rating";; roll_width) echo "Roll Width";; horizontal_repeat) echo "Horizontal Repeat";; vertical_repeat) echo "Vertical Repeat";; designer) echo Designer;; esac; }
+echo "$TARGETS" | while IFS='|' read -r pid series; do
+  [ -z "$pid" ] && continue
+  # 1) delete the wrongly-written spec metafields
+  curl -s "$BASE/products/$pid/metafields.json?namespace=custom" -H "$H" | python3 -c '
+import sys,json
+keys=set("'"$SPECKEYS"'".split())
+for m in json.load(sys.stdin).get("metafields",[]):
+    if m["key"] in keys: print(m["id"])' | while read -r mid; do
+      curl -s -o /dev/null -w "" -X DELETE "$BASE/metafields/$mid.json" -H "$H"; sleep 0.2
+    done
+  echo "[$pid] deleted wrong specs${series:+ ; re-writing from '$series'}"
+  # 2) re-write from correct series if provided
+  if [ -n "$series" ]; then
+    spec=$(python3 -c "import json;print(json.dumps(json.load(open('kor_series2spec.json')).get('$series',{})))")
+    for k in $SPECKEYS; do
+      lbl=$(label_for "$k"); val=$(echo "$spec" | python3 -c "import sys,json;print(json.load(sys.stdin).get('$lbl',''))")
+      [ -z "$val" ] && continue
+      body=$(python3 -c "import json,sys;print(json.dumps({'metafield':{'namespace':'custom','key':'$k','type':'$(mk $k)','value':sys.argv[1]}}))" "$val")
+      curl -s -o /dev/null -w "" -X POST "$BASE/products/$pid/metafields.json" -H "$H" -H "Content-Type: application/json" -d "$body"; sleep 0.2
+    done
+    echo "[$pid]   re-wrote from $series"
+  fi
+  sleep 0.3
+done
+echo "SPEC-FIX DONE"
diff --git a/spec_fix_targets.json b/spec_fix_targets.json
new file mode 100644
index 0000000..bd4183d
--- /dev/null
+++ b/spec_fix_targets.json
@@ -0,0 +1 @@
+[{"mfr": "5021-16", "pid": "7584945700915", "pattern": "Grande Golden Harvest", "matched": "harvest", "correct": "grande"}, {"mfr": "LN21-84", "pid": "7585016119347", "pattern": "Lino Early Harvest Gray", "matched": "harvest", "correct": null}, {"mfr": "2082-90", "pid": "7519958728755", "pattern": "Le Embossed Raffia Oliver Twist", "matched": "oliver", "correct": null}, {"mfr": "SG13-03", "pid": "7584894877747", "pattern": "Coney Aspen", "matched": "aspen", "correct": "coney"}, {"mfr": "NW21-11", "pid": "7584918503475", "pattern": "Niwa Stream", "matched": "stream", "correct": "niwa"}]
\ No newline at end of file

← 9fa129d Koroseal reconcile DONE: 87 reactivated+published; 1,573 SKU  ·  back to Koroseal Goodrich Audit  ·  auto-save: 2026-07-26T08:41:50 (1 files) — mfr_width_writeli e51912f →