{"id":1639,"date":"2021-03-14T02:29:54","date_gmt":"2021-03-14T02:29:54","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/get-product-salable-quantity-in-magento-2\/"},"modified":"2025-05-22T10:51:25","modified_gmt":"2025-05-22T05:21:25","slug":"get-product-salable-quantity-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/get-product-salable-quantity-in-magento-2\/","title":{"rendered":"How to Get Product Salable Quantity in Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The release of&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/magento-2-3-3-release\/\" target=\"_blank\" rel=\"noreferrer noopener\">Magento 2.3.3<\/a>&nbsp;introduced the concept of salable quantity.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you have&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/download-magento\/\" target=\"_blank\" rel=\"noreferrer noopener\">downloaded the Magento 2.3.3&nbsp;<\/a>version, you might have seen the salable quantity and quantity in the product grid.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Salable Quantity is the sum of available resources, grouped in stocks. Salable quantity gets changed when the order is placed or the physical quantity in the warehouse changes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now, the merchants can link multiple inventory sources to one or multiple websites and manage their inventory in more than one location to accurately reflect their physical inventories without any 3rd party extensions!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">While working on inventory management, a need may arrive to apply validation or conditions based on salable quantity.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For instance, the admin may want to hide the SKU and stock status if the salable quantity is zero and if it is greater than zero, show the SKU and stock status in Magento 2 store.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the above scenario, we have to pass the condition on a salable quantity. To do so, we need to&nbsp;get product salable quantity in Magento 2.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The product grid displays the salable quantity in Magento 2 store:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2021\/03\/ss-1024x327.jpg\" alt=\"How to get Salable Quantity\" class=\"wp-image-13733\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Use the below method and get the salable quantity programmatically in Magento 2.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method to Get Product Salable Quantity in Magento 2<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">use Magento\\InventorySalesAdminUi\\Model\\GetSalableQuantityDataBySku; \nprivate $getSalableQuantityDataBySku;\n\npublic function __construct(GetSalableQuantityDataBySku $getSalableQuantityDataBySku) \n{\n    $this->getSalableQuantityDataBySku = $getSalableQuantityDataBySku;\n}\n\npublic function getProductSalableQty()\n{\n    $sku = \"simple_blue\";\n    $salable = $this->getSalableQuantityDataBySku->execute($sku);\n    echo json_encode($salable);\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Get salable quantity using ObjectManager<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n$objectManager = \\Magento\\Framework\\App\\ObjectManager::getInstance();\n$StockState = $objectManager->get('\\Magento\\InventorySalesAdminUi\\Model\\GetSalableQuantityDataBySku');\n$qty = $StockState->execute($_product->getSku());\necho($qty[0]['qty']);\n?><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s all!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Feel free to share the solution with Magento Community via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank You.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The release of&nbsp;Magento 2.3.3&nbsp;introduced the concept of salable quantity. If you have&nbsp;downloaded the Magento 2.3.3&nbsp;version, you might have seen the salable quantity and quantity in&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-1639","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1639","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=1639"}],"version-history":[{"count":4,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1639\/revisions"}],"predecessor-version":[{"id":14443,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1639\/revisions\/14443"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=1639"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=1639"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=1639"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}