How to Get Product Salable Quantity in Magento 2

A Magento store that has multi-source inventory (MSI) enabled will have a salable quantity (qty), which represents the total quantity of all available products for purchase across all stores. It’s important to note that the salable quantity is different from the actual quantity when MSI is enabled. If you need to retrieve the salable quantity, this blog post will guide you through the process.

What is Salable Quantity?

The salable quantity represents the stock available for sale after accounting for reservations made for pending orders. It provides a more accurate picture of the inventory available for customer purchase.

How to get a Salable qty of product using SKU in Magento 2

Following is the sample code to get salable qty in Adobe commerce.

<?php
namespace Dhairvi\Test\Model;

class ClassName
{
    /**
     * @var \Magento\InventorySalesAdminUi\Model\GetSalableQuantityDataBySku
     */
    protected $getSalableQuantityDataBySku;
	
    /**
     * @param \Magento\InventorySalesAdminUi\Model\GetSalableQuantityDataBySku $getSalableQuantityDataBySku
     */
    public function __construct(
        \Magento\InventorySalesAdminUi\Model\GetSalableQuantityDataBySku $getSalableQuantityDataBySku
    ) {
        $this->getSalableQuantityDataBySku = $getSalableQuantityDataBySku;
    }
    
    public function getSalableQtyBySku($sku)
    {
        return $this->getSalableQuantityDataBySku->execute($sku);
    }
}

In the output, you will get all the available sources and the total quantity available to purchase.

Privacy Policy © 2024-2026 Dhairvi Solutions LLP. All Rights Reserved.