商品

商品资源使您可以在商人的商店中更新和创建商品。您可以将商品变体与商品资源一起使用来创建或更新同一商品的不同版本。您还可以添加或更新商品图像。

您可以使用CustomCollection资源和SmartCollection资源将商品添加到集合中。

您可以用商品做什么

Shopify API使您可以对商品资源执行以下操作。这些常规操作的更详细的版本可能可用:

商品特性

body_html plain "body_html": "It's the small iPod with a big idea: Video." 商品说明。支持HTML格式。
created_at 只读 plain "created_at": "2012-02-15T15:12:21-05:00" 商品创建 的日期和时间(ISO 8601格式)。
处理 plain "handle": "ipod-nano" 商品的独特的人性化字符串。自动从商品的生成title。Liquid模板语言使用它来引用对象。
ID 只读 plain "id": 632910392 一个无符号的64位整数,用作商品的唯一标识符。每个id在Shopify系统中都是唯一的。id即使两种商品来自不同的商店,也不会有相同的商品。
图片 plain "images": [ { "id": 850703190, "product_id": 632910392, "position": 1, "created_at": "2018-01-08T12:34:47-05:00", "updated_at": "2018-01-08T12:34:47-05:00", "width": 110, "height": 140, "src": "http://example.com/burton.jpg", "variant_ids": [ {} ] } ] 商品图像对象的 列表,每个代表与商品关联的图像。
选项 plain "options": [ { "name": "Title" } ] 自定义商品属性名称一样Size,Color和Material。您最多可以添加3个选项,每个选项最多255个字符。
商品类别 plain "product_type": "Cult Products" 用于过滤和搜索商品的商品的分类。
已发布 plain "published_at": "2007-12-31T19:00:00-05:00" 商品发布 的日期和时间(ISO 8601格式)。可以设置为null从在线商店频道取消发布商品。
published_scope plain "published_scope": "global" 商品是否发布到销售点渠道。有效值:
+ web:商品已发布到“在线商店”渠道,但未发布到“销售点”渠道。
+ global:商品同时发布到在线商店渠道和销售点渠道。
状态 plain "status": "active" 商品的状态。有效值:
+ active:商品已准备就绪,可以在网上商店,销售渠道和应用程序上向客户购买。默认情况下,现有商品设置为活动。
+ archived:该商品不再销售,并且无法通过销售渠道和应用程序向客户提供。
+ draft:该商品尚未准备好销售,并且在销售渠道和应用上对客户不可用。默认情况下,重复和未存档商品设置为草稿。
标签 plain "tags": "Emotive, Flash Memory, MP3, Music" 一串用逗号分隔的标签,用于过滤和搜索。一个商品最多可以包含250个标签。每个标签最多可包含255个字符。
template_suffix plain "template_suffix": "special" 商品页面使用的Liquid模板的后缀。如果指定了此属性,那么商品页面将使用名为“ product.suffix.liquid”的模板,其中“ suffix”是此属性的值。如果此属性是""或null,那么商品页面将使用默认模板“ product.liquid”。(默认值:null)
标题 必需的 plain "title": "IPod Nano - 8GB" 商品名称。
Updated_at 只读 plain "updated_at": "2012-08-24T14:01:47-04:00" 商品上次修改 的日期和时间(ISO 8601格式)。商品的updated_at价值可能因不同的原因而变化。例如,如果下达了具有库存跟踪设置的商品的订单,则将库存调整计为更新。
变体 plain "variants": [ { "barcode": "1234_pink", "compare_at_price": null, "created_at": "2012-08-24T14:01:47-04:00", "fulfillment_service": "manual", "grams": 567, "weight": 0.2, "weight_unit": "kg", "id": 808950810, "inventory_item_id": 341629, "inventory_management": "shopify", "inventory_policy": "continue", "inventory_quantity": 10, "option1": "Pink", "position": 1, "price": 199.99, "presentment_prices": [ { "price": { "currency_code": "USD", "amount": "199.99" }, "compare_at_price": null }, { "price": { "currency_code": "EUR", "amount": "158.95" }, "compare_at_price": null }, { "price": { "currency_code": "GBP", "amount": "143.00" }, "compare_at_price": null }, { "price": { "currency_code": "JPY", "amount": "22400" }, "compare_at_price": null } ], "product_id": 632910392, "requires_shipping": true, "sku": "IPOD2008PINK", "taxable": true, "title": "Pink", "updated_at": "2012-08-24T14:01:47-04:00" } ] 商品变体的列表,每个代表商品的不同版本。
该position属性是只读的。变体的位置由其列出的顺序指示。
要检索presentment_prices变量的属性,请包含request标头'X-Shopify-Api-Features': 'include-presentment-prices'。
小贩 plain "vendor": "Apple" 商品供应商的名称。

终点

得到/admin/api/2021-01/products.json 检索商品列表。注意:从2019-07版本开始,此端点通过使用响应标头中提供的链接来实现分页。发送<font style="background-color:#F4F6F8;">page</font>参数将返回错误。要了解更多信息,请参阅向分页的REST Admin API端点发出请求。
编号 仅返回由逗号分隔的商品ID列表指定的商品。
限制 每页最多返回这么多结果。
(默认值:50
最大:250
)
since_id 仅返回指定ID之后的商品。
标题 按商品标题退回商品。
小贩 按商品标题退回商品。
处理 仅返回由逗号分隔的商品句柄列表指定的商品。
商品类别 按商品类型退货。
状态 仅返回由逗号分隔的状态列表指定的商品。
(默认值:any
)
+ active:仅返回有效商品。
+ 已归档:仅返回已归档的商品。
+ 草稿:仅返回草稿商品。
collection_id 按商品集合ID返回商品。
created_at_min 返回指定日期之后创建的商品。(格式:2014-04-25T16:15:47-04:00)
created_at_max 返回指定日期之前创建的商品。(格式:2014-04-25T16:15:47-04:00)
Updated_at_min 返回指定日期后最后更新的商品。(格式:2014-04-25T16:15:47-04:00)
Updated_at_max 返回指定日期之前最后更新的商品。(格式:2014-04-25T16:15:47-04:00)
Published_at_min 返回指定日期之后发布的商品。(格式:2014-04-25T16:15:47-04:00)
published_at_max 返回指定日期之前发布的商品。(格式:2014-04-25T16:15:47-04:00)
已发布状态 按发布状态退货
(默认值:any
)
+ 已发布:仅返回已发布的商品。
+ 未发布:仅返回未发布的商品。
+ 任何:退回所有商品。
领域 仅返回由逗号分隔的字段名称列表指定的某些字段。
present_currencies 仅以某些货币返回展示价格,这些货币由逗号分隔的ISO 4217货币代码列表指定。

检索所有商品

GET /admin/api/2021-01/products.json

查看回应

检索特定商品的列表。

GET /admin/api/2021-01/products.json?ids=632910392,921728736

查看回应

检索所有商品,仅显示一些属性

GET /admin/api/2021-01/products.json?fields=id,images,title

查看回应

检索属于某个集合的所有商品

GET /admin/api/2021-01/products.json?collection_id=841564295

查看回应

在指定的ID之后检索所有商品

GET /admin/api/2021-01/products.json?since_id=632910392

查看回应

检索所有具有所选演示货币价格的商品

GET /admin/api/2021-01/products.json?presentment_currencies=USD

查看回应

得到/admin/api/2021-01/products/count.json 检索商品数量。
小贩 按商品标题退回商品。
商品类别 按商品类型退货。
collection_id 按商品集合ID返回商品。
created_at_min 返回指定日期之后创建的商品。(格式:2014-04-25T16:15:47-04:00)
created_at_max 返回指定日期之前创建的商品。(格式:2014-04-25T16:15:47-04:00)
Updated_at_min 返回指定日期后最后更新的商品。(格式:2014-04-25T16:15:47-04:00)
Updated_at_max 返回指定日期之前最后更新的商品。(格式:2014-04-25T16:15:47-04:00)
Published_at_min 返回指定日期之后发布的商品。(格式:2014-04-25T16:15:47-04:00)
published_at_max 返回指定日期之前发布的商品。(格式:2014-04-25T16:15:47-04:00)
已发布状态 按发布状态退货
(默认值:any
)
+ 已发布:仅返回已发布的商品。
+ 未发布:仅返回未发布的商品。
+ 任何:退回所有商品。

检索所有商品的计数

GET /admin/api/2021-01/products/count.json

查看回应

检索给定集合中所有商品的计数

GET /admin/api/2021-01/products/count.json?collection_id=841564295

查看回应

得到/admin/api/2021-01/products/{product_id}.json 检索单个商品。
领域 以逗号分隔的字段列表,包括在响应中。

通过ID检索单个商品

GET /admin/api/2021-01/products/632910392.json

查看回应

仅检索特定字段

GET /admin/api/2021-01/products/632910392.json?fields=id,图片,标题

查看回应

邮政/admin/api/2021-01/products.json

创建一个新商品。

如果要设置商品的SEO信息,则可以使用以下属性:

  • metafields_global_title_tag:用于SEO的商品名称。通常添加到<meta name='title'>标签中。
  • metafields_global_description_tag:用于SEO的商品说明。通常添加到<meta name='description'>标签中。

使用默认商品变体创建新商品

POST /admin/api/2021-01/products.json

{

“商品” : {

  1. 标题:“ Burton Custom Freestyle 151”,
  2. “ body_html” :“ <strong>单板滑雪好!</ strong>”,
  3. “供应商” :“伯顿”,
  4. “ product_type” :“滑雪板”,
  5. “标签” : [
  6. “ Barnes&Noble”,
  7. “ John's Fav”,
  8. “ \ Big Air \”
  9. ]

}

}

查看回应

创建一个新的未发布的商品

POST /admin/api/2021-01/products.json

{

“商品” : {

  1. 标题:“ Burton Custom Freestyle 151”,
  2. “ body_html” :“ <strong>单板滑雪好!</ strong>”,
  3. “供应商” :“伯顿”,
  4. “ product_type” :“滑雪板”,
  5. “已发布” :false

}

}

查看回应

创建一个新的草稿商品

POST /admin/api/2021-01/products.json

{

“商品” : {

  1. 标题:“ Burton Custom Freestyle 151”,
  2. “ body_html” :“ <strong>单板滑雪好!</ strong>”,
  3. “供应商” :“伯顿”,
  4. “ product_type” :“滑雪板”,
  5. “商店” : {
  6. “ id” :690933842,
  7. “名称” :“苹果计算机”,
  8. “电子邮件” :“ steve@apple.com”,
  9. “域” :“ apple.myshopify.com”,
  10. “省” :“加利福尼亚”,
  11. “ country” :“ US”,
  12. “ address1” :“ 1个无限循环”,
  13. “ zip” :“ 95014”,
  14. “ city” :“ Cupertino”,
  15. “源” :null,
  16. “ phone” :“ 1231231234”,
  17. “纬度” :45.45,
  18. “经度” :-75.43,
  19. “ primary_locale” :“ en”,
  20. “ address2” :“套房100”,
  21. “ created_at” :“ 2007-12-31T19:00:00-05:00”,
  22. “ updated_at” :“ 2021-02-17T19:22:04-05:00”,
  23. “ country_code” :“美国”,
  24. “ country_name” :“美国”,
  25. “ currency” :“ USD”,
  26. “ customer_email” :“ steve@apple.com”,
  27. “ timezone” :“(GMT-05:00)美国东部时间(美国和加拿大)”,
  28. “ iana_timezone” :“美国/纽约”,
  29. “ shop_owner” :“史蒂夫·乔布斯”,
  30. “ money_format” :“ $”,
  31. “ money_with_currency_format” :“ $ USD”,
  32. “ weight_unit” :“ lb”,
  33. “ province_code” :“ CA”,
  34. “ taxes_included” :null,
  35. “ auto_configure_tax_inclusivity” :null,
  36. “ tax_shipping” :null,
  37. “ county_taxes” :是,
  38. “ plan_display_name” :“ Shopify Plus”,
  39. “ plan_name” :“企业”,
  40. “ has_discounts” :是,
  41. “ has_gift_cards” :是,
  42. “ myshopify_domain” :“ apple.myshopify.com”,
  43. “ google_apps_domain” :null,
  44. “ google_apps_login_enabled” :null,
  45. “ money_in_emails_format” :“ $”,
  46. “ money_with_currency_in_emails_format” :“ $ USD”,
  47. “ eligible_for_payments” :true,
  48. “ requires_extra_payments_agreement” :false,
  49. “ password_enabled” :null,
  50. “ has_storefront” :是,
  51. “ eligible_for_card_reader_giveaway” :false,
  52. “财务” :真实,
  53. “ primary_location_id” :905684977,
  54. “ cookie_consent_level” :“隐式”,
  55. “ visitor_tracking_consent_preference” :“ allow_all”,
  56. “ force_ssl” :是,
  57. “ checkout_api_supported” :是,
  58. “ multi_location_enabled” :false,
  59. “ setup_required” :false,
  60. “ pre_launch_enabled” :false,
  61. “ enabled_presentment_currencies” : [
  62. “ USD”
  63. ]
  64. },
  65. “状态” :“草稿”

}

}

查看回应

创建具有多个商品变型的新商品

POST /admin/api/2021-01/products.json

{

“商品” : {

标题:“ Burton Custom Freestyle 151”,

“ body_html” :“ <strong>单板滑雪好!</ strong>”,

“供应商” :“伯顿”,

“ product_type” :“滑雪板”,

“变体” : [

  {

    “ option1” :“第一”,

    “价格” :“ 10.00”,

    “ sku” :“ 123”

  },

  {

    “ option1” :“第二个”,

    “价格” :“ 20.00”,

    “ sku” :“ 123”

  }

]

}

}

查看回应

创建具有多个商品变体和多个选项的新商品

POST /admin/api/2021-01/products.json

{

“商品” : {

标题:“ Burton Custom Freestyle 151”,

“ body_html” :“ <strong>单板滑雪好!</ strong>”,

“供应商” :“伯顿”,

“ product_type” :“滑雪板”,

“变体” : [

  {

    “ option1” :“蓝色”,

    “ option2” :“ 155”

  },

  {

    “ option1” :“黑色”,

    “ option2” :“ 159”

  }

],

“选项” : [

  {

    “名称” :“颜色”,

    “值” : [

       “蓝色”,

       “黑色”

    ]

  },

  {

    “名称” :“大小”,

    “值” : [

       “ 155”,

       “ 159”

    ]

  }

]

}

}

查看回应

创建具有默认变体和base64编码图像的新商品

POST /admin/api/2021-01/products.json

{

“商品” : {

标题:“ Burton Custom Freestyle 151”,

“ body_html” :“ <strong>单板滑雪好!</ strong>”,

“供应商” :“伯顿”,

“ product_type” :“滑雪板”,

“图像” : [

  {

    “ attachment” :“ R0lGODlhAQABAIAAAAAAAAAAACHACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw == \ n”

  }

]

}

}

查看回应

创建具有默认变体的新商品和Shopify将下载的商品图片

POST /admin/api/2021-01/products.json

{

“商品” : {

标题:“ Burton Custom Freestyle 151”,

“ body_html” :“ <strong>单板滑雪好!</ strong>”,

“供应商” :“伯顿”,

“ product_type” :“滑雪板”,

“图像” : [

  {

    “ src” :“ [http://example.com/rails_logo.gif](http://example.com/rails_logo.gif)”

  }

]

}

}

查看回应

创建没有标题的商品将返回错误

POST /admin/api/2021-01/products.json

{

“商品” : {

“ body_html” :“一个谜!

}

}

查看回应

使用元字段创建商品

POST /admin/api/2021-01/products.json

{

“商品” : {

标题:“ Burton Custom Freestyle 151”,

“ body_html” :“ <strong>单板滑雪好!</ strong>”,

“供应商” :“伯顿”,

“ product_type” :“滑雪板”,

“ metafields” : [

  {

    “ key” :“ new”,

    “ value” :“ newvalue”,

    “ value_type” :“字符串”,

    “ namespace” :“ global”

  }

]

}

}

查看回应

放/admin/api/2021-01/products/{product_id}.json

更新商品及其变体和图像。

如果要更新商品的SEO信息,则可以使用以下属性:

  • metafields_global_title_tag:用于SEO的商品名称。通常添加到<meta name='title'>标签中。
  • metafields_global_description_tag:用于SEO的商品说明。通常添加到<meta name='description'>标签中。

通过重新订购商品变型来更新商品

PUT /admin/api/2021-01/products/632910392.json

{

“商品” : {

“ id” :632910392,

“变体” : [

  {

    “ id” :457924702

  },

  {

    “ id” :39072856

  },

  {

    “ id” :49148385

  },

  {

    “ id” :808950810

  }

]

}

}

查看回应

更新商品及其变体之一

PUT /admin/api/2021-01/products/632910392.json

{

“商品” : {

“ id” :632910392,

"title": "Updated Product Title",

"variants": [

  {

    "id": 808950810,

    "price": "2000.00",

    "sku": "Updating the Product SKU"

  },

  {

    "id": 49148385

  },

  {

    "id": 39072856

  },

  {

    "id": 457924702

  }

]

}

}

View Response

Update a product’s SEO title and description

PUT /admin/api/2021-01/products/632910392.json

{

“product”: {

"id": 632910392,

"metafields_global_title_tag": "Brand new title",

"metafields_global_description_tag": "Brand new description"

}

}

View Response

Show a hidden product by changing the published attribute to true

PUT /admin/api/2021-01/products/632910392.json

{

“product”: {

"id": 632910392,

"published": true

}

}

View Response

Hide a published product by changing the published attribute to false

PUT /admin/api/2021-01/products/632910392.json

{

“product”: {

"id": 632910392,

"published": false

}

}

View Response

Add a metafield to an existing product

PUT /admin/api/2021-01/products/632910392.json

{

“product”: {

"id": 632910392,

"metafields": [

  {

    "key": "new",

    "value": "newvalue",

    "value_type": "string",

    "namespace": "global"

  }

]

}

}

View Response

Update a product’s title

PUT /admin/api/2021-01/products/632910392.json

{

“product”: {

"id": 632910392,

"title": "New product title"

}

}

View Response

Update a product’s status

PUT /admin/api/2021-01/products/632910392.json

{

“product”: {

"id": 632910392,

"status": "draft"

}

}

View Response

Update a product’s tags

PUT /admin/api/2021-01/products/632910392.json

{

“product”: {

"id": 632910392,

"tags": "Barnes & Noble, John's Fav"

}

}

View Response

Update a product by clearing product images

PUT /admin/api/2021-01/products/632910392.json

{

“product”: {

"id": 632910392,

"images": []

}

}

View Response

Update a product by adding a new product image

PUT /admin/api/2021-01/products/632910392.json

{

“product”: {

"id": 632910392,

"images": [

  {

    "id": 850703190

  },

  {

    "id": 562641783

  },

  {

    "src": "http://example.com/rails_logo.gif"

  }

]

}

}

View Response

Update a product by reordering product image

PUT /admin/api/2021-01/products/632910392.json

{

“product”: {

"id": 632910392,

"images": [

  {

    "id": 850703190,

    "position": 2

  },

  {

    "id": 562641783,

    "position": 1

  }

]

}

}

View Response

DELETE/admin/api/2021-01/products/{product_id}.json Deletes a product.

Delete a product along with all its variants and images

DELETE /admin/api/2021-01/products/632910392.json

View Response