وضع الدفعة

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

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

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

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

لا تستخدِم productId إلا إذا كنت تنفّذ عملية get أو delete. لا يكون productId مطلوبًا في طلب بيانات من واجهة برمجة التطبيقات لإجراء `insert` في 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
  }
 ]
}