Files
apps-registry/workloads/ecommerce/tools/catalog_sync.py
T
devops 27d1ad992d
Build and Push Frontend / build (push) Successful in 1m22s
feat(ecommerce): release Ari Shopping Frontend v2.1 real catalog
2026-07-19 16:21:44 -05:00

38 lines
1.5 KiB
Python

#!/usr/bin/env python3
from __future__ import annotations
import csv, json
from datetime import datetime, timezone
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
SRC = ROOT / 'catalog-source.csv'
OUT = ROOT / 'data/products.json'
def to_bool(v: str) -> bool:
return str(v).strip().lower() in {'1','true','yes','si','sí'}
def main() -> int:
products = []
with SRC.open(newline='', encoding='utf-8-sig') as handle:
for row in csv.DictReader(handle):
products.append({
'id': row['id'].strip(),
'name': row['name'].strip(),
'category': row['category'].strip(),
'collection': row['collection'].strip(),
'description': row['description'].strip(),
'dimensions': row['dimensions'].strip(),
'price': None,
'priceText': 'Consultar disponibilidad',
'available': to_bool(row['available']),
'featured': to_bool(row['featured']),
'new': to_bool(row['new']),
'image': row['image'].strip(),
'fbid': row['fbid'].strip(),
})
OUT.write_text(json.dumps({'version':'2.2.0','updatedAt':datetime.now(timezone.utc).isoformat(),'pricingMode':'consult','products':products}, ensure_ascii=False, indent=2), encoding='utf-8')
print(f'OK: {len(products)} productos escritos en {OUT}')
return 0
if __name__ == '__main__':
raise SystemExit(main())