מצב אצווה

אפשר להשתמש ב-custombatch כדי insert,‏ get או delete כמה מוצרים בו-זמנית בקריאה אחת ל-API.

כדי לבצע קריאה לממשקי ה-API המותאמים אישית לפעולות מקובצות, משתמשים בכתובת ה-URL הבאה של הבקשה:

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

גוף הבקשה מכיל פרמטרים ספציפיים: batchId, merchantID ו-method.

משתמשים ב-productId רק כשמבצעים פעולת get או delete. הפרמטר productId לא נדרש בקריאה ל-API של custombatch מסוג insert.

custombatch:insert

כתובת ה-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:get

כתובת ה-URL של הבקשה הבאה מבצעת קריאה ל-products.custombatch עם method=get:

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

כדי לקבל מוצר, צריך לציין בקריאה ל-API את batchId שהוא ייחודי למוצר, את merchantId של המוכר שמורשה לבצע את הקריאה ל-API, את ה-method 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: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
  }
 ]
}