Пакетный режим

Вы можете использовать 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: вставить

Следующий URL-адрес запроса используется для создания products.custombatch method=insert

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

Чтобы вставить два новых продукта, укажите batchId для каждого продукта, merchantId продавца, уполномоченного выполнять вызов API, и метод insert .

В следующем примере значения batchId равны 1111 и 1112 соответственно и являются уникальными идентификаторами для каждого продукта. merchantId: 1234567 — это продавец, которому разрешен вызов API, а метод — get , delete или insert .

insert создает новый продукт. Если для данного продукта существуют значения атрибутов channel , contentLanguage , offerId и feedLabel , этот метод обновляет запись и заменяет все данные из предыдущих вызовов API для продукта.

Вот пример тела JSON для 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: получить

Следующий URL-адрес запроса выполняет вызов products.custombatch с method=get :

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

Чтобы получить продукт, укажите уникальный идентификатор batchId для вызова API, merchantId продавца, уполномоченного выполнить вызов API, метод get и productId продукта извлекаемого продукта.

Ниже приведен пример тела запроса JSON для получения двух продуктов, вставленных с использованием предыдущего примера 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
 
}
 
]
}