skip to Main Content

I’m bulk-creating items using the bulkCreateOrReplaceInventoryItem API. Some of my products are listed under the wrong categories. I can’t find any field in the request payload by which I can mention the category id of each item.

Here are the API docs: https://developer.ebay.com/api-docs/sell/inventory/resources/inventory_item/methods/bulkCreateOrReplaceInventoryItem

Can anyone help me provide the category details while creating new items on eBay?

Here is my request payload:

foreach ($data as $key => $item) {
    $o = array(
        "sku" => $item['sku'],
        "locale" => $item['locale'],
        "product" => array(
            "title" => $item['title'],
            "description" => $item['description'],
            "aspects" => array(),
            "brand" => $item['brand'],
            "mpn" => $item['mpn'],
            "imageUrls" => $item['images'],
            "aspects" => $item['aspects']
        ),
        "condition" => $item['condition'],
        // "conditionDescription" => $item['conditionDescription'],
        "availability" => array(
            "shipToLocationAvailability" => array(
                "quantity" => $item['quantity']
            )
        ),
    );
    if ($item['condition'] != 'NEW') {
        $o['conditionDescription'] = $item['conditionDescription'];
    }
    $object[] = $o;
}
$object = array('requests' => $object);

2

Answers


  1. you’d want to use the product field and specify the primaryProductCategory field to set the category for the item. The primaryProductCategory is a container that is used to identify the primary category in which the item will be listed on eBay.

    foreach ($data as $key => $item) {
        $o = array(
            "sku" => $item['sku'],
            "locale" => $item['locale'],
            "product" => array(
                "title" => $item['title'],
                "description" => $item['description'],
                "aspects" => array(),
                "brand" => $item['brand'],
                "mpn" => $item['mpn'],
                "imageUrls" => $item['images'],
                "aspects" => $item['aspects'],
                "primaryProductCategory" => array(
                    "categoryId" => $item['categoryId']
                )
            ),
            "condition" => $item['condition'],
            // "conditionDescription" => $item['conditionDescription'],
            "availability" => array(
                "shipToLocationAvailability" => array(
                    "quantity" => $item['quantity']
                )
            ),
        );
        if ($item['condition'] != 'NEW') {
            $o['conditionDescription'] = $item['conditionDescription'];
        }
        $object[] = $o;
    }
    $object = array('requests' => $object);
    

    In the above code, I added the primaryProductCategory array into the product array. You’ll need to make sure that your $item array includes the categoryId key, and its value should be the ID of the category you want to list the item under. The value of categoryId should be a string.

    Login or Signup to reply.
  2. How can I add the variations of the products to this request ?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search