How to update qty and stock status using API for multiple products in Magento 2?
We are doing ERP integration with Magento 2 and we need to update qty and stock status.
in magento 1 we had catalogInventoryStockItemUpdate
Soap API for update.
I have search in magento 2 API and found below:
catalogInventoryStockRegistryV1
PUT /V1/products/{productSku}/stockItems/{itemId}
catalogProductRepositoryV1
PUT /V1/products/{sku}
But they only work for a single SKU.
What is the equivalent of catalogInventoryStockItemUpdate
in Magento 2 API, Where we can pass an array of SKU for update qty and stock
Thanks in advance!
Best Answer
Try this bulk endpoints
To call a bulk endpoint, add the prefix /async/bulk before the /V1 of the asynchronous endpoint route. For example:
Endpoint routes that contain input parameters require additional changes. For example, PUT /V1/products/:sku/media/:entryId contains the :SKU and :entryId input parameters. The route of a bulk request cannot contain input parameters, so you must change the route so that it does not contain any. To do this, replace the colon (:) with by and change the first letter of the parameter to uppercase.
it means your request join data should contain entry_id and SKU for each product.
Updates:
I have tried the below and it is working fine for me, before trying the below you should install rabbitmq and add queue configuration in app/etc/env.php
e.g) env.php
Request data:
Response
If cron configured, it will automatically trigger otherwise you need to run the below command manually to trigger the queue
You can check this queue status in Magento admin -> System -> Bulk Action Log with the above response bulk_uuid (eda7899f-d00b-4d0a-b6f9-77fea3296f4d) Easy for your reference: https://nimb.ws/qnA6oY