โหมดกลุ่ม

คุณใช้ custombatch เพื่อ insert, get หรือ delete ผลิตภัณฑ์หลายรายการพร้อมกันได้ในการเรียก API 1 ครั้ง

ใช้ URL คำขอต่อไปนี้เพื่อเรียก API กลุ่มที่กำหนดเอง

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

เนื้อหาของคำขอมีพารามิเตอร์ที่เจาะจง: batchId, merchantID และ method

โปรดใช้ productId ในกรณีที่คุณดำเนินการรับหรือลบเท่านั้น ไม่จำเป็นต้องมี productId ในการแทรกการเรียก API สำหรับ custombatch

custombatch:insert

มีการใช้ URL คำขอต่อไปนี้ในการสร้าง products.custombatch method=insert

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

หากต้องการแทรกผลิตภัณฑ์ใหม่ 2 รายการ ให้ระบุ batchId สำหรับผลิตภัณฑ์แต่ละรายการ, merchantId ของผู้ขายที่ได้รับอนุญาตให้เรียก API และวิธีการ insert

ในตัวอย่างต่อไปนี้ ค่า batchId คือ 1111 และ 1112 ตามลำดับ และเป็นตัวระบุที่ไม่ซ้ำกันสำหรับผลิตภัณฑ์แต่ละรายการ merchantId: 1234567 เป็นผู้ขายที่ได้รับอนุญาตให้เรียก API และเมธอดคือ get, delete หรือ insert

insert สร้างผลิตภัณฑ์ใหม่ หากค่าสำหรับแอตทริบิวต์ channel, contentLanguage, offerId และ feedLabel ของผลิตภัณฑ์หนึ่งๆ มีอยู่ วิธีนี้จะอัปเดตรายการและแทนที่ข้อมูลทั้งหมดจากการเรียก API ก่อนหน้าของผลิตภัณฑ์

ต่อไปนี้คือตัวอย่างเนื้อหา JSON สำหรับ insert เสื้อยืด 2 ตัวลงในฐานข้อมูล Merchant Center โดยใช้การเรียก API เดียว

{
  "entries": [
    {
      "batchId": 1111,
      "merchantId": 1234567,
      "method": "insert",
      "product": {
        "kind": "content#product",
        "offerId": "1111111111",

        "title": "Google Tee Black",
        "description": "The Black Google Tee is available in unisex sizing and
        features a retail fit.",
        "link": "http://my.site.com/blacktee/",
        "imageLink": "https://shop.example.com/.../images/GGOEGXXX1100.jpg",
        "contentLanguage": "en",
        "targetCountry": "US",
        "feedLabel": "US",
        "channel": "online",
        "ageGroup": "adult",
        "availability": "in stock",
        "availabilityDate": "2019-01-25T13:00:00-08:00",
        "brand": "Google",
        "color": "black",
        "condition": "new",
        "gender": "male",
        "googleProductCategory": "1604",
        "gtin": "608802531656",
        "itemGroupId": "google_tee",
        "mpn": "608802531656",
        "price": {
          "value": "21.99",
          "currency": "USD"
        },
        "sizes": [
          "Large"
        ],
        "includedDestination": [
          "Shopping"
        ]
      }
    },
    {
      "batchId": 1112,
      "merchantId": 1234567,
      "method": "insert",
      "product": {
        "kind": "content#product",
        "offerId": "2222222222",

        "title": "Google Tee Green",
        "description": "100% cotton jersey fabric sets  this Google t-shirt above
        the crowd. Features the google logo across the chest. Unisex sizing.",
        "link": "http://my.site.com/greentee/",
        "imageLink": "https://shop.example.com/.../images/GGOEGXXX0906.jpg",
        "contentLanguage": "en",
        "targetCountry": "US",
        "feedLabel": "US",
        "channel": "online",
        "ageGroup": "adult",
        "availability": "in stock",
        "availabilityDate": "2019-01-25T13:00:00-08:00",
        "brand": "Google",
        "color": "green",
        "condition": "new",
        "gender": "male",
        "googleProductCategory": "1604",
        "gtin": "608802531649",
        "itemGroupId": "google_tee",
        "mpn": "608802531649",
        "price": {
          "value": "21.99",
          "currency": "USD"
        },
        "sizes": [
          "Medium"
        ],
        "includedDestination": [
          "Shopping"
        ]
      }
    }
  ]
}

การเรียก API ที่สำเร็จจะแสดงผลโค้ด HTTP 200 และการตอบสนอง JSON ที่รวมผลิตภัณฑ์ที่แทรกไว้ รูปแบบของ JSON ที่แสดงผล จะคล้ายกับรูปแบบต่อไปนี้

{
 "kind": "content#productsCustomBatchResponse",
 "entries": [
  {
   "kind": "content#productsCustomBatchResponseEntry",
   "batchId": 1111,
   "product": {
    "kind": "content#product",
    "id": "online:en:US:1111111111",
    "offerId": "1111111111",
    "title": "Google Tee Black",
    "description": "The Black Google Tee is available in unisex sizing and
    features a retail fit.",
    "link": "http://my.site.com/blacktee/",
    "imageLink": "https://shop.example.com/.../images/GGOEGXXX1100.jpg",
    "contentLanguage": "en",
    "targetCountry": "US",
    "feedLabel": "US",
    "channel": "online",
    "ageGroup": "adult",
    "availability": "in stock",
    "availabilityDate": "2019-01-25T13:00:00-08:00",
    "brand": "Google",
    "color": "black",
    "condition": "new",
    "gender": "male",
    "googleProductCategory": "1604",
    "gtin": "608802531656",
    "itemGroupId": "google_tee",
    "mpn": "608802531656",
    "price": {
     "value": "21.99",
     "currency": "USD"
    },
    "sizes": [
     "Large"
    ],
    "includedDestination": [
      "Shopping"
    ]
   }
  },
  {
   "kind": "content#productsCustomBatchResponseEntry",
   "batchId": 1112,
   "product": {
    "kind": "content#product",
    "id": "online:en:US:2222222222",
    "offerId": "2222222222",
    "title": "Google Tee Green",
    "description": "100% cotton jersey fabric sets this Google t-shirt above
    the crowd. Features the google logo across the chest. Unisex sizing.",
    "link": "http://my.site.com/greentee/",
    "imageLink": "https://shop.example.com/.../images/GGOEGXXX0906.jpg",
    "contentLanguage": "en",
    "targetCountry": "US",
    "feedLabel": "US",
    "channel": "online",
    "ageGroup": "adult",
    "availability": "in stock",
    "availabilityDate": "2019-01-25T13:00:00-08:00",
    "brand": "Google",
    "color": "green",
    "condition": "new",
    "gender": "male",
    "googleProductCategory": "1604",
    "gtin": "608802531649",
    "itemGroupId": "google_tee",
    "mpn": "608802531649",
    "price": {
     "value": "21.99",
     "currency": "USD"
    },
    "sizes": [
     "Medium"
    ],
    "includedDestination": [
      "Shopping"
    ]
   }
  }
 ]
}

custombatch:get

URL คำขอต่อไปนี้ทำการเรียก products.custombatch ด้วย method=get:

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

หากต้องการผลิตภัณฑ์ ให้ระบุ batchId ที่ไม่ซ้ำกันสำหรับผลิตภัณฑ์ในการเรียก API, merchantId ของผู้ขายที่ได้รับอนุญาตให้เรียก API, วิธี get และ productId ของผลิตภัณฑ์ที่กำลังดึงข้อมูล

ต่อไปนี้เป็นตัวอย่างเนื้อหาคำขอ JSON สำหรับการดึงข้อมูลผลิตภัณฑ์ 2 รายการที่แทรกโดยใช้ตัวอย่าง custombatch:insert ก่อนหน้า ซึ่งระบุด้วยค่า productId batchId ที่ไม่ซ้ำกันสำหรับแต่ละรายการในลิสต์รายการมีดังนี้

{
  "entries": [
    {
      "batchId": 1113,
      "merchantId": 1234567,
      "method": "get",
      "productId": "online:en:US:1111111111"
    },
    {
      "batchId": 1114,
      "merchantId": 1234567,
      "method": "get",
      "productId": "online:en:US:2222222222"
    }
  ]
}

การเรียกนี้จะแสดงรหัส HTTP 200 และเนื้อหาการตอบสนองต่อไปนี้:

{
 "kind": "content#productsCustomBatchResponse",
 "entries": [
  {
   "kind": "content#productsCustomBatchResponseEntry",
   "batchId": 1113,
   "product": {
    "kind": "content#product",
    "id": "online:en:US:1111111111",
    "offerId": "1111111111",
    "title": "Google Tee Black",
    "description": "The Black Google Tee is available in unisex sizing and features a retail fit.",
    "link": "http://my.site.com/blacktee/",
    "imageLink": "https://shop.example.com/.../images/GGOEGXXX1100.jpg",
    "contentLanguage": "en",
    "targetCountry": "US",
    "feedLabel": "US",
    "channel": "online",
    "ageGroup": "adult",
    "availability": "in stock",
    "availabilityDate": "2019-01-25T13:00:00-08:00",
    "brand": "Google",
    "color": "black",
    "condition": "new",
    "gender": "male",
    "googleProductCategory": "1604",
    "gtin": "608802531656",
    "itemGroupId": "google_tee",
    "mpn": "608802531656",
    "price": {
     "value": "21.99",
     "currency": "USD"
    },
    "sizes": [
     "Large"
    ],
    "includedDestination": [
      "Shopping"
    ]
   }
  },
  {
   "kind": "content#productsCustomBatchResponseEntry",
   "batchId": 1114,
   "product": {
    "kind": "content#product",
    "id": "online:en:US:2222222222",
    "offerId": "2222222222",
    "title": "Google Tee Green",
    "description": "100% cotton jersey fabric sets this Google t-shirt above the crowd.
    Features the google logo across the chest. Unisex sizing.",
    "link": "http://my.site.com/greentee/",
    "imageLink": "https://shop.example.com/.../images/GGOEGXXX0906.jpg",
    "contentLanguage": "en",
    "targetCountry": "US",
    "feedLabel": "US",
    "channel": "online",
    "ageGroup": "adult",
    "availability": "in stock",
    "availabilityDate": "2019-01-25T13:00:00-08:00",
    "brand": "Google",
    "color": "green",
    "condition": "new",
    "gender": "male",
    "googleProductCategory": "1604",
    "gtin": "608802531649",
    "itemGroupId": "google_tee",
    "mpn": "608802531649",
    "price": {
     "value": "21.99",
     "currency": "USD"
    },
    "sizes": [
     "Medium"
    ],
    "includedDestination": [
      "Shopping"
    ]
   }
  }
 ]
}

custombatch:ลบ

ระบบใช้ URL คำขอต่อไปนี้ในการสร้าง products.custombatch ที่มี method=delete

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

หากต้องการลบผลิตภัณฑ์ ให้ระบุ batchId ที่ไม่ซ้ำกันสำหรับผลิตภัณฑ์ภายในการเรียก API นี้, merchantId ของผู้ขายที่ได้รับอนุญาตให้เรียก API นี้, เมธอด delete และ productId ของผลิตภัณฑ์ที่กำลังลบ

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

การเรียกนี้จะแสดงรหัส HTTP 200 และค่า batchId ของรายการที่ถูกลบดังนี้

{
 "kind": "content#productsCustomBatchResponse",
 "entries": [
  {
   "kind": "content#productsCustomBatchResponseEntry",
   "batchId": 1115
  },
  {
   "kind": "content#productsCustomBatchResponseEntry",
   "batchId": 1116
  }
 ]
}