How to categorize products when creating them using the Python GraphQL Admin API.

Topic summary

用户尝试通过 Python GraphQL Admin API 创建产品并指定产品类别时遇到问题。

问题描述:

  • 使用 product.category 字段设置类别 ID(格式:gid://shopify/TaxonomyCategory/aa-1-12-4
  • 提交后类别设置无效,产品无法成功添加到指定类别

代码示例:

product = shopify.Product()
product.category = "gid://shopify/TaxonomyCategory/aa-1-12-4"
product.vendor = "Only"
product.title = "产品标题"
product.body_html = "产品描述"
product.product_type = "Jeans"

当前状态:
问题尚未解决,等待社区提供正确的类别设置方法或 API 使用建议。

Summarized with AI on November 5. AI used: claude-sonnet-4-5-20250929.

I want to create a product, specify the category of the product, and wrote the category field, but the submission has been invalid. Products cannot be added to categories.

product = shopify.Product()
product.category = " gid://shopify/TaxonomyCategory/aa-1-12-4 "
product.product_type = “Jeans”
product.body_html = “
- WOMEN’S SKINNY JEANS
- COLLECTION: AUTUMN/WINTER
- COMPOSITION: 70% COTTON, 27% POLYESTER, 3%/ELASTANE

product.title = “15092650 - ONLROYAL LIFE REG SKINNY 600 NOOS”
product.vendor = “Only”
product.save()