将补充 Feed 与 Content API 结合使用

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

例如,您可以将 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 的情况下调用 products.insert 不同, 删除所有现有商品数据并将其替换为您在邮件中 请求正文。

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

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

您必须将 offerIdfeedLabelchannelcontentLanguage 字段。所有其他字段都是选填字段。

示例

要将商品的库存状况从“in stock”更改为“out of stock”,您需要 可以使用以下请求正文创建补充 Feed Product.insert 方法调用:

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

products.delete

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

使用以下网址请求补充 Feed products.delete 服务,其中 productIdREST ID 商品的属性,表示为:channel:contentLanguage:feedLabel:offerId

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

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

products.custombatch

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

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

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

对于所有补充 Feed custombatch 调用,都必须添加 batchId, 请求中的 merchantIDmethodfeedId 参数 正文。

products.custombatch:insert

products.custombatch:insert 方法进行补充 Feed 调用时, 必须包含 offerIdfeedLabelchannelcontentLanguage,除了必需的 batchId 外, merchantIDmethod 参数。其他所有商品字段均为选填。

示例

如需更新两个现有商品的 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"
    }
  ]
}