将补充 Feed 与 Content API 结合使用

您可以使用补充 Feed 对商品数据进行部分更新,方法是在调用 products.insertproducts.deleteproducts.custombatch.insertproducts.custombatch.delete 方法时将 feedId 添加为查询参数。

例如,您可以对以下网址进行 products.insert 补充 Feed 方法调用:

POST https://shoppingcontent.googleapis.com/content/v2.1/merchantId/products?feedId=feedId

products.insert

补充 Feed products.insert 方法会添加您在请求正文中发送的商品字段,并覆盖这些字段(如果存在)。使用补充 Feed 时,此方法不会更改所有其他商品字段,除非这些字段已包含在针对同一 Feed 的先前请求中。虽然通过其他 Feed 添加的数据不受影响,但每个请求都会覆盖之前针对同一 Feed 发出的请求。这意味着,如果您通过补充 Feed 请求添加或更新某个字段,而后又未在后续请求中包含该字段,系统将从 Feed 中移除被省略字段的数据。此行为与在没有补充 Feed 的情况下调用 products.insert 不同,后者会删除所有现有商品数据,并将其替换为您在请求正文中发送的字段。

使用以下网址向补充 Feed Product.insert 服务发出请求:

POST https://shoppingcontent.googleapis.com/content/v2.1/merchantId/products?feedId=feedId

您必须在请求正文中添加 offerIdfeedLabelchannelcontentLanguage 字段。所有其他字段都是选填字段。

示例

如需将商品的库存状况从“有货”更改为“缺货”,您可以使用以下请求正文进行补充 Feed Product.insert 方法调用:

{
 "offerId": "1111111111",
 "contentLanguage": "en",
 "feedLabel": "US",
 "channel": "online",
 "availability": "out of stock",
}

products.delete

products.delete 方法可移除之前由 products.insert 调用使用指定的补充 Feed 添加的所有补充数据。为补充 Feed 调用此方法不会影响在调用补充 Feed Product.insert 之前添加的原始商品数据。您可以将此操作视为为某个特定 Feed 移除一层数据;通过其他 Feed 添加的数据不会受到影响,并且该产品实际上会恢复到添加补充 Feed 层之前的状态。这与在没有补充 Feed 的情况下调用 products.delete 不同,后者会删除整个商品及其所有数据。

使用以下网址向补充 Feed products.delete 服务发出请求,其中 productId 是商品的 REST ID,表示为:channel:contentLanguage:feedLabel:offerId

DELETE https://shoppingcontent.googleapis.com/content/v2.1/merchantId/products/productId?feedId=feedId

补充 Feed products.delete 方法调用不需要请求正文。

products.custombatch

借助 custombatch 方法,您可以使用单次 API 调用为多件商品提供 insertdelete 补充 Feed 数据,从而最大限度地减少 API 调用的次数。

使用以下请求网址进行 custombatch 调用:

https://shoppingcontent.googleapis.com/content/v2.1/products/batch

对于所有补充 Feed custombatch 调用,您必须在请求正文中添加 batchIdmerchantIDmethodfeedId 参数。

products.custombatch:insert

products.custombatch:insert 方法进行补充 Feed 调用时,除了必需的 batchIdmerchantIDmethod 参数之外,您还必须在请求正文中添加 offerIdfeedLabelchannelcontentLanguage。所有其他商品字段均为选填字段。

示例

如需更新两个现有商品的 price 值,您可以使用以下请求进行 products.custombatch:insert 方法调用:

{
  "entries": [
    {
      "batchId": 1111,
      "merchantId": 1234567,
      "method": "insert",
      "feedId": "7654321",
      "product": {
         "offerId": "1111111111",
         "contentLanguage": "en",
         "targetCountry": "US",
         "feedLabel": "US",
         "channel": "online",
         "price": {
          "value": "30.99",
          "currency": "USD"
         }
      }
    },
    {
      "batchId": 1112,
      "merchantId": 1234567,
      "method": "insert",
      "feedId": "7654321",
      "product": {
         "offerId": "2222222222",
         "contentLanguage": "en",
         "targetCountry": "US",
         "feedLabel": "US",
         "channel": "online",
         "price": {
          "value": "33.99",
          "currency": "USD"
         },
      },
    }
}

products.custombatch:delete

如需移除通过指定的补充 Feed 对两件商品进行的所有更新,您可以使用以下请求进行 products.custombatch:delete 方法调用:

{
  "entries": [
    {
      "batchId": 1115,
      "merchantId": 1234567,
      "method": "delete",
      "feedId": "7654321",
      "productId": "online:en:US:1111111111"
    },
    {
      "batchId": 1116,
      "merchantId": 1234567,
      "method": "delete",
      "feedId": "7654321",
      "productId": "online:en:US:2222222222"
    }
  ]
}