وضع الدفعة

يمكنك استخدام custombatch من أجل insert أو get أو delete منتجات متعددة في الوقت نفسه من خلال طلب بيانات واحد من واجهة برمجة التطبيقات.

استخدِم عنوان URL التالي لطلب بيانات من واجهات برمجة التطبيقات المجمّعة المخصّصة:

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

يحتوي نص الطلب على مَعلمات محدّدة: batchId وmerchantID وmethod.

لا تستخدِم productId إلا إذا كنت تنفّذ عملية get أو delete. لا يلزم توفّر productId في طلب بيانات من واجهة برمجة التطبيقات لإدراج custombatch.

custombatch:insert

يتم استخدام عنوان URL التالي للطلب لإجراء products.custombatch method=insert

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

لإدراج المنتجين الجديدين، حدِّد batchId لكل منتج وmerchantId للتاجر المفوّض بإجراء طلب البيانات من واجهة برمجة التطبيقات، بالإضافة إلى الطريقة insert.

في المثال التالي، قيم batchId هي 1111 و1112 على التوالي، وهما معرّفان فريدان لكل منتج. merchantId: 1234567 هو التاجر المفوّض بإجراء طلب البيانات من واجهة برمجة التطبيقات، والطريقة هي get أو delete أو insert.

تنشئ insert منتجًا جديدًا. إذا كانت هناك قيم للسمات channel وcontentLanguage وofferId وfeedLabel لمنتج معيّن، تعدّل هذه الطريقة الإدخال وتستبدل جميع البيانات من طلبات البيانات السابقة من واجهة برمجة التطبيقات للمنتج.

في ما يلي نموذج لنص JSON لإضافة insert قميصَين إلى قاعدة بيانات Merchant Center باستخدام طلب واحد من واجهة برمجة التطبيقات:

{
  "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"
        ]
      }
    }
  ]
}

يعرض طلب البيانات الناجح من واجهة برمجة التطبيقات الرمز 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 الفريد للمنتج في طلب البيانات من واجهة برمجة التطبيقات، وmerchantId الخاص بالتاجر المصرّح له بإجراء طلب البيانات من واجهة برمجة التطبيقات، والطريقة 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 الفريد للمنتج ضمن طلب البيانات من واجهة برمجة التطبيقات هذا، وmerchantId الخاص بالتاجر المفوّض بإجراء طلب البيانات من واجهة برمجة التطبيقات هذا، والطريقة 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
  }
 ]
}