magento / magento/inventory

Introduce REST endpoints to fetch saleable quantity / stock data for a list of skus

Open
#3,415 2 comments 1 reaction 0 assignees View on GitHub
Progress: ready for grooming
Dominant language
PHP
Stars
357
Forks
262
PR merge metrics
No merged PRs in 30d

Description

### Description (*)
According to the documentation at https://developer.adobe.com/commerce/webapi/rest/inventory/check-salable-quantity/
We currently have REST endpoints for checking both, if a single sku or multiples skus are saleable. Via the following routes
```
GET /V1/inventory/is-product-salable/:sku/:stockId
GET /V1/inventory/are-products-salable/:skus[]/:stockId
```

Although when it comes to fetching the actual saleable quantity, there is only a endpoint to check a singular product at a time.
```
GET /V1/inventory/get-product-salable-quantity/:sku/:stockId
```

In the context of external ERP systems / marketplaces, it quite common to perform regular stock retrieval from Magento to ensure accurate stock counts. Currently this means making a single request for each product, which for large catalogs can amount to a lot of requests & wasted bandwidth compared to being able to batch multiple products into a single request.

### Expected behavior (*)
Offer a endpoint to fetch saleable qty for multiple products similar to `are-products-saleable`.
```
GET GET /V1/inventory/get-products-salable-quantities/:sku[]/:stockId
```

### Benefits
- Reduction in needed REST calls for fetching stock data when working with large sets of catalog products.
- Reduction in system & database load (compared to individual calls per product)
- Reduced bandwidth usage & carbon emissions (compared to individual calls per product)

### Additional information
Functionality seems to be a popular request in the magento2 repository, with people requiring stockItems on the product list endpoint, see the references below.
- https://github.com/magento/magento2/issues/24418
- https://github.com/magento/magento2/issues/36533
- https://github.com/magento/magento2/pull/36615
- https://github.com/magento/magento2/pull/28435

See the following comment on one of the PRs from Sidolov, around removing the stock data from the catalog REST endpoints. Although currently there seems to be no alternative to bulk load stock/qty data for a set of skus. https://github.com/magento/magento2/pull/28435#issuecomment-638320655

Contributor guide

Open the contributing guide

Research direction

Start with the documented inventory REST endpoints for checking single and multiple saleable products, then compare them with the existing single-product saleable-quantity endpoint. Add the corresponding multiple-SKU quantity entry point and verify that it returns saleable quantities for the requested SKUs and stock ID in one request.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api, backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.