Request Quote

Get Salable Quantity in Magento 2.3

Get Salable Quantity in Magento 2.3

In the latest Magento version 2.3, you might have noticed an additional quantity parameter ‘Salable Quantity‘. Today we will see how to get a product’s salable quantity in Magento 2.3

Unlike 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 salable quantity gets reduced. The quantity of the product decrease only after shipping is completed.

To get salable quantity use the following code –

namespace Webkul\Module\ModelName;
use Magento\InventorySalesAdminUi\Model\GetSalableQuantityDataBySku;
class ClassName
    private $getSalableQuantityDataBySku;
    public function __construct(
        GetSalableQuantityDataBySku $getSalableQuantityDataBySku
    ) {
        $this->getSalableQuantityDataBySku = $getSalableQuantityDataBySku;
    public function execute(\Magento\Framework\Event\Observer $observer)
        $sku = "testsimpleproduct1";
        $salable = $this->getSalableQuantityDataBySku->execute($sku);
        echo json_encode($salable);

This will give output as –

[{"stock_name":"Default Stock","qty":4,"manage_stock":true}]

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

Hope this helps.

Happy coding 🙂


. . .

Comments (2)

Add Your Comment

  • chris
    is there a way to skip the reservation ?
    We would like to skip the “The quantity of the product decrease only after shipping is completed.” part to how it was before .
    • Paul Dutta
      Skipping salable quantity will be a problem as it has been implemented in many places. However you can try and update this file Magento\InventoryReservations\Model\ResourceModel\GetReservationsQuantity.php, where salable quantity is calculated. So you can try and modify this file to get the product actual qty, or you can simply use previous Magento 2 version.
  • css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again