How to get saleable qty when MSI is enabled
It's very hard to get saleable qty when you enabled MSI in Magento and you have more than 1 source of inventory. the below code will helpful for fetching qty from the Source of inventory.
Read More
1 2 3 4 5 6 7 8 9 10 11 |
$product_sku = 'SIMBEEZ00001'; $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $storeManager = $objectManager->get('\Magento\Store\Model\StoreManagerInterface'); $stockResolver = $objectManager->get('\Magento\InventorySalesApi\Api\StockResolverInterface'); $productSalabe = $objectManager->get('\Magento\InventorySalesApi\Api\GetProductSalableQtyInterface'); $stockId = $stockResolver->execute(\Magento\InventorySalesApi\Api\Data\SalesChannelInterface::TYPE_WEBSITE, $storeManager->getWebsite()->getCode())->getStockId(); $stockQty = $productSalable->execute($product_sku, $stockId); echo $stockQty; |