In today’s Magento 2 tutorial, I am going to illustrate how to obtain a salable quantity of product in Magento 2.
The functionality of Salable Quantity was introduced first with the release of Magento 2.3. Salable quantity allows managing the warehouse and avoiding out-of-stock conditions.
When an order is issued the quantity of the product does not reduce. Only the salable quantity is decreased. The quantity decreases after the order is shipped. Hence, the quantity and salable quantity are not always the same.
Solve the issue – quantity availability showing in stock even if the salable quantity is 0
Admin needs to keep an eye on salable quantity to manage inventory. Use the following code to get the salable quantity of product in Magento 2.
Steps to Get Product Salable Quantity in Magento 2:
Step 1: Create the following helper file in your extension
Then add the below code
class Data extends AbstractHelper
public function __construct(
$this->getSalableQtyDataBySku = $getSalableQtyDataBySku;
public function getSalableQtyBySku($sku)
$salable = $this->getSalableQuantityDataBySku->execute($sku);
You will get the following Output:
And that’s it! You can easily fetch the salable quantity of product in Magento 2. If you are unable to get the desired output of a salable quantity, reach out to me via the comment section. Share the solution with your friends and stay updated for more tutorials.