HF_AGENT / product_builder_tools.py
Brettapps's picture
Syncing files from local MCP agent storage
2ee34e0 verified
Raw
History Blame Contribute Delete
766 Bytes
import shopify
import json
def create_shopify_product(title, body_html, vendor, product_type, tags, price):
"""Creates a new product in Shopify."""
try:
new_product = shopify.Product()
new_product.title = title
new_product.body_html = body_html
new_product.vendor = vendor
new_product.product_type = product_type
new_product.tags = tags
# Add variant
variant = shopify.Variant({'price': price, 'sku': title.replace(" ", "-").lower()})
new_product.variants = [variant]
new_product.save()
return json.dumps({"status": "success", "product_id": new_product.id})
except Exception as e:
return json.dumps({"status": "error", "message": str(e)})