← back to Dw Yolo Loop

thibaut-mfr-fix/README.md

48 lines

# Thibaut mfr-SKU placement fix

Goal (Steve, 2026-06-11): every Thibaut product has its **manufacturer number in the tags, not in the title**.

Scope audited: 3,612 Thibaut products (`vendor_prefix='DWTT'`).

## State

| Task | Count | Status |
|---|---|---|
| Tag backfill — add mfr SKU as a clean tag where missing (active) | 1,027 | ✅ **PUSHED LIVE** 2026-06-11 (direct Admin REST, 0 failed) |
| Title de-SKU — auto-fixable rewrites | 69 | ✅ **PUSHED LIVE** 2026-06-11 (0 failed) |
| Title de-SKU — needs real pattern name | 10 | backlog → `BACKLOG.md` |
| Junk parenthetical tags `Pattern(SKU)` | ~160 | backlog → `BACKLOG.md` |

Everything is staged in PG table **`thibaut_mfr_fix_staging`** (`id, shopify_id, fix_type, mfr_sku, old_value, new_value, status`).

## Write path
Pushes go through `shopify_api_queue` → the `shopify-queue-worker` (runs on Kamatera,
`/root/DW-Agents/shopify-queue-worker/worker.js`, ~950 jobs/day ceiling). The queue table is
bidirectionally replicated, so jobs enqueued on Mac2 reach the worker. Shopify REST `PUT` merges —
sending only `{product:{id,tags}}` changes tags **without** touching title/variants/images.

Contract (proven, from `DW-Programming/justindavid-shopify-push.js`):
`INSERT INTO shopify_api_queue(method,endpoint,payload,token_alias,priority,source_agent,status)`
`method='PUT'`, `endpoint='/products/<numeric_id>.json'`, `token_alias='product'`, `status='pending'`.

## To push the 69 titles once approved
```sql
INSERT INTO shopify_api_queue (method, endpoint, payload, token_alias, priority, source_agent, status)
SELECT 'PUT',
       '/products/'||split_part(shopify_id,'/',5)||'.json',
       jsonb_build_object('product', jsonb_build_object(
           'id', split_part(shopify_id,'/',5)::bigint, 'title', new_value)),
       'product', 5, 'thibaut-mfr-title-fix', 'pending'
FROM thibaut_mfr_fix_staging
WHERE fix_type='title' AND shopify_id ~ '^gid://shopify/Product/[0-9]+$' AND status='staged';

UPDATE thibaut_mfr_fix_staging SET status='queued'
WHERE fix_type='title' AND shopify_id ~ '^gid://shopify/Product/[0-9]+$' AND status='staged';
```

## Re-run the title transformer (preview only)
```sh
python3 title_scrub.py            # preview AUTOFIX / BACKLOG buckets
python3 title_scrub.py --emit     # also write /tmp/thibaut_title_proposals.tsv
```