[object Object]

← back to Designer Wallcoverings

Carl Robinson: push material-inclusive titles (City Material Color | Phillipe Romano) to live products

5d6aa242e1044ec38e9d1ee24db57d07f05b1d14 · 2026-07-06 12:32:26 -0700 · steve@designerwallcoverings.com

Files touched

Diff

commit 5d6aa242e1044ec38e9d1ee24db57d07f05b1d14
Author: steve@designerwallcoverings.com <steve@designerwallcoverings.com>
Date:   Mon Jul 6 12:32:26 2026 -0700

    Carl Robinson: push material-inclusive titles (City Material Color | Phillipe Romano) to live products
---
 .../update-shopify-titles-carl-robinson.cjs        | 43 ++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/scripts/wallquest-refresh/update-shopify-titles-carl-robinson.cjs b/scripts/wallquest-refresh/update-shopify-titles-carl-robinson.cjs
new file mode 100644
index 00000000..0f913c2f
--- /dev/null
+++ b/scripts/wallquest-refresh/update-shopify-titles-carl-robinson.cjs
@@ -0,0 +1,43 @@
+// Update the 67 live Carl Robinson product TITLES to include the material descriptor
+// (Cork / Grasscloth / Paperweave / Mica / Netting …). Format: "{City} {Material} {Color} | Phillipe Romano".
+// Anchors on carl_robinson_catalog.shopify_product_id. Idempotent (skips if already correct). No "Wallpaper".
+const https = require('https');
+const { Client } = require('pg');
+const STORE = 'designer-laboratory-sandbox.myshopify.com';
+const API = '2024-10';
+const TOKEN = process.env.SHOPIFY_ADMIN_TOKEN;
+if (!TOKEN) { console.error('no SHOPIFY_ADMIN_TOKEN'); process.exit(1); }
+const CONN = process.env.DATABASE_URL || 'postgresql://dw_admin@127.0.0.1:5432/dw_unified';
+const sleep = ms => new Promise(r => setTimeout(r, ms));
+const clean = s => s.replace(/\bWallpapers?\b/gi, 'Wallcovering');
+
+function rest(method, path, body) {
+  return new Promise((resolve, reject) => {
+    const data = body ? JSON.stringify(body) : null;
+    const req = https.request({ hostname: STORE, path: `/admin/api/${API}${path}`, method,
+      headers: { 'X-Shopify-Access-Token': TOKEN, 'Content-Type': 'application/json', ...(data ? { 'Content-Length': Buffer.byteLength(data) } : {}) }, timeout: 40000 },
+      res => { let d = ''; res.on('data', c => d += c); res.on('end', () => { try { resolve({ status: res.statusCode, j: d ? JSON.parse(d) : {} }); } catch (e) { resolve({ status: res.statusCode, raw: d }); } }); });
+    req.on('error', reject); req.on('timeout', () => { req.destroy(); reject(new Error('timeout')); });
+    if (data) req.write(data); req.end();
+  });
+}
+
+(async () => {
+  const db = new Client({ connectionString: CONN }); await db.connect();
+  const { rows } = await db.query(`SELECT shopify_product_id, pattern_name, color_name FROM carl_robinson_catalog WHERE shopify_product_id IS NOT NULL ORDER BY dw_sku`);
+  console.log(`updating ${rows.length} product titles (material-inclusive)…`);
+  let set = 0, already = 0, err = 0;
+  for (const r of rows) {
+    const title = clean(`${r.pattern_name}${r.color_name ? ' ' + r.color_name : ''} | Phillipe Romano`); // e.g. "Kennebunkport Cork Chalk | Phillipe Romano"
+    try {
+      const cur = await rest('GET', `/products/${r.shopify_product_id}.json?fields=id,title`);
+      if (cur.j?.product?.title === title) { already++; continue; }
+      const u = await rest('PUT', `/products/${r.shopify_product_id}.json`, { product: { id: r.shopify_product_id, title } });
+      if (u.status >= 200 && u.status < 300) { set++; console.log(`✓ ${title}`); }
+      else { err++; console.log(`✗ ${r.shopify_product_id} HTTP ${u.status}`); }
+    } catch (e) { err++; console.log(`✗ ${r.shopify_product_id} ${String(e).slice(0, 80)}`); }
+    await sleep(550);
+  }
+  console.log(`\nTITLE UPDATE DONE: set=${set} already-correct=${already} errors=${err}`);
+  await db.end();
+})().catch(e => { console.error('FATAL', e.message); process.exit(1); });

← 2347c1e6 Carl Robinson: fix publish-channels to anchor on carl_robins  ·  back to Designer Wallcoverings  ·  Daisy Bennett GO LIVE: 63 products active on Shopify (Philli 04409a10 →