โหมดกลุ่ม

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

ใช้ 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 สำหรับเสื้อยืด 2 ตัวของ insert ใน 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:delete

ใช้ 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
 
}
 
]
}