← back to Elitis Price 2026
exec/probe_qty_by_unit.py
24 lines
import csv, sys, json
sys.path.insert(0,'exec/lib')
from shopify import find_product_by_title, gql
# Sample one product per unit from OUT_223 and read its qty/packaging metafields
rows=list(csv.DictReader(open("OUT_223_priced.csv")))
by_unit={}
for r in rows:
by_unit.setdefault(r["unit"],[]).append(r)
def mfmap(node):
return { f"{e['node']['namespace']}.{e['node']['key']}": e['node']['value'] for e in node["metafields"]["edges"] }
for unit,rs in by_unit.items():
r=rs[0]
n=find_product_by_title(r["title"])
if not n:
print(f"{unit}: {r['title']!r} -> NOT FOUND"); continue
m=mfmap(n)
keys=["global.packaged","global.v_prods_quantity_order_min","global.v_prods_quantity_order_units",
"global.width","global.length","specs.width","specs.roll_length","global.Contents"]
print(f"\n=== UNIT={unit} ({len(rs)} products) ex: {r['title']}")
for k in keys: print(f" {k} = {m.get(k)!r}")