Reading list Switch to dark mode

    Get Salable Quantity in Magento 2.3

    Updated 26 March 2024

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

    Salable_Quantity

    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()
        {
            $sku = "testsimpleproduct1";
            $salable = $this->getSalableQuantityDataBySku->execute($sku);
            echo json_encode($salable);
        }
    }

    This will give the output as –

    Searching for an experienced
    Magento 2 Company ?
    Find out More

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

    Hope this helps. Please visit our Magento 2 affiliate Extension.

    Happy coding 🙂

    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    10 comments

  • Teja Bhagavan Kollepara
    • Paul Dutta (Moderator)
  • nikhil garg
    • Paul Dutta (Moderator)
  • GOpal Gautam
    • Paul Dutta (Moderator)
  • Seniore T
    • Paul Dutta (Moderator)
  • chris
    • Paul Dutta (Moderator)
  • Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home