---
title: "Magento 2 Get Product Salable Quantity Programmatically"
url: "https://dolphinwebsolution.com/magento-2-get-product-salable-quantity-programmatically"
date: "2021-09-27T07:39:19+05:30"
modified: "2023-08-24T10:04:52+05:30"
author:
  name: "Jigar Patel"
categories:
  - "Magento"
word_count: 343
reading_time: "2 min read"
summary: "The Salable Quantity first appears in Magento 2.3 release together with the Multi-Source Inventory system. It allows you to manage all your warehouses in one place and avoid dead stocks and out-of-..."
description: "Since Magento 2.3 and higher versions, you can see the additional column at the product grid - salable quantity. I will instruct you to Get Product Salable Q..."
keywords: "product Salable Quantity Programmatically,Salable Quantity Programmatically,magento 2 Salable Quantity Programmatically,magento Salable Quantity Programmatically,magento product salable quantity, Magento"
language: "en"
schema_type: "Article"
related_posts:
  - title: "How to create Install, Upgrade, Uninstall Script in Magento 2"
    url: "https://dolphinwebsolution.com/how-to-create-install-upgrade-uninstall-script-in-magento-2"
  - title: "How To Implement Field Dependency  In System Configuration Magento 2"
    url: "https://dolphinwebsolution.com/how-to-implement-field-dependency-in-system-configuration-magento-2"
  - title: "How to add additional text based on selected shipping methods in the checkout"
    url: "https://dolphinwebsolution.com/how-to-add-additional-text-based-on-selected-shipping-methods-in-the-checkout"
---

# Magento 2 Get Product Salable Quantity Programmatically

_Published: September 27, 2021_  
_Author: Jigar Patel_  

![](https://dolphinwebsolution.com/wp-content/uploads/2023/02/Magento-2-Get-product-salable-1024x536.png)

The Salable Quantity first appears in Magento 2.3 release together with the Multi-Source Inventory system. It allows you to manage all your warehouses in one place and avoid dead stocks and out-of-stock situations.

You can see the additional column at the product grid – salable quantity.

The product grid salable quantity.

![AI Integration in Magento: Benefits, Use Cases and Business Impact](https://dolphinwebsolution.com/wp-content/uploads/2021/09/Products-Inventory-Catalog-Magento-Admin-1024x292.png)

**Salable Quantity** is the sum of available resources, grouped in stocks.

In previous versions of Magento, the quantity of a product does not decrease when an order is placed. Instead, the quantity remains the same but the **salable quantity** gets reduced. The quantity of the product decrease only after [shipping](https://dolphinwebsolution.com/shop/magento-2-extensions/shipping.html) is completed.

### How To Get Product Salable Quantity In Magento 2
Get Product Salable Quantity Programmatically through two methods.

**Method 1:** Using getSalableQuantityDataBySku method.

**Method 2:** Using The Object Manager

#### Using getSalableQuantityDataBySku method
```
<?php

use Magento\InventorySalesAdminUi\Model\GetSalableQuantityDataBySku;
private $getSalableQuantityDataBySku;

public function __construct(GetSalableQuantityDataBySku $getSalableQuantityDataBySku)
{
    $this->getSalableQuantityDataBySku = $getSalableQuantityDataBySku;
}

public function getProductSalableQty($sku)
{
    $salable = $this->getSalableQuantityDataBySku->execute($sku);
    echo json_encode($salable);
}
```

Now, you can get value by call **getSalabelQty()** function in your module file. You need to pass parameter of product sku in the function. You can call function by this below line.

**$block->getSalabelQty(’24-MB04′);**

Here, **24-MB04** is product sku. You will get array of salable qty details.

**This will give output:-**

```
[dt_code][{"stock_name":"Default Stock","qty":100,"manage_stock":true}][/dt_code]
```

- **qty** is salable quantity not the actual quantity of the product.We get actual quantity of the product by ***$product->getQty()**.*

#### Using The Object Manager
```
<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$StockState = $objectManager->get('\Magento\InventorySalesAdminUi\Model\GetSalableQuantityDataBySku');
$qty = $StockState->execute($_product->getSku());
echo($qty[0]['qty']);
?>
```

- **$objectManager:** The object manager itself is an instance of the Magento\\Framework\\ObjectManager\\ObjectManager
    class that implements the Magento\\Framework\\ObjectManagerInterface class.The object manager can instantiate a PHP class, which can
    be a model, helper, or block object.

If you have any queries regarding this post, use the comment section below!

Happy Coding!

Thank you for reading.


---

_View the original post at: [https://dolphinwebsolution.com/magento-2-get-product-salable-quantity-programmatically](https://dolphinwebsolution.com/magento-2-get-product-salable-quantity-programmatically)_  
_Served as markdown by [Third Audience](https://github.com/third-audience) v3.5.3_  
_Generated: 2026-08-26 06:53:25 UTC_  
