← back to Twil Golive 2026 07
rebrand3.mjs
25 lines
// Rebrand the 3 no-twin TWIL stubs to Phillipe Romano series names, activate, publish.
const TOKEN = process.env.SHOPIFY_ADMIN_TOKEN;
const EP = 'https://designer-laboratory-sandbox.myshopify.com/admin/api/2024-07/graphql.json';
const PUB = 'gid://shopify/Publication/22208643184';
const items = [
{ gid: 'gid://shopify/Product/7822233370675', title: 'Lecce Papiro - Dark Blue Wallcovering | Phillipe Romano' }, // WP7593
{ gid: 'gid://shopify/Product/7822233468979', title: 'Lecce Papiro - Beige Wallcovering | Phillipe Romano' }, // WP7596
{ gid: 'gid://shopify/Product/7822233763891', title: 'Como Seta - Khaki Wallcovering | Phillipe Romano' }, // WS5128
];
async function gql(query, variables) {
const r = await fetch(EP, { method: 'POST', headers: { 'X-Shopify-Access-Token': TOKEN, 'Content-Type': 'application/json' }, body: JSON.stringify({ query, variables }) });
const j = await r.json();
if (j.errors) throw new Error(JSON.stringify(j.errors));
return j.data;
}
for (const it of items) {
const before = await gql('query($id:ID!){ product(id:$id){ title vendor status } }', { id: it.gid });
console.log('BEFORE', JSON.stringify(before.product));
const u = await gql(`mutation($input: ProductInput!){ productUpdate(input:$input){ product{ title vendor status } userErrors{ message } } }`,
{ input: { id: it.gid, title: it.title, vendor: 'Phillipe Romano', status: 'ACTIVE' } });
if (u.productUpdate.userErrors.length) { console.log('ERR', JSON.stringify(u.productUpdate.userErrors)); continue; }
await gql(`mutation($id:ID!,$input:[PublicationInput!]!){ publishablePublish(id:$id,input:$input){ userErrors{ message } } }`, { id: it.gid, input: [{ publicationId: PUB }] });
console.log('AFTER ', JSON.stringify(u.productUpdate.product));
}