Is it possible to show a list of products with a negative salable qty in magento 2.3

1 Answer 1


You can get through by looping the product collection an checking the -ve salable qty like this.

        $negativeSalableQtySkus = [];
        $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
        /** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $productCollection */
        $productCollection = $objectManager->create('Magento\Catalog\Model\ResourceModel\Product\Collection');
        /** Apply filters here */
        $collection = $productCollection->addAttributeToSelect('*')->load();
        foreach ($collection as $product) {
            $sku = $product->getSku();
            $StockState = $objectManager->get('\Magento\InventorySalesAdminUi\Model\GetSalableQuantityDataBySku');
            $stock = $StockState->execute($sku);
            if (isset($stock[0])) {
                $qty = $stock[0]['qty'];
                if ($qty < 0) {
                    $negativeSalableQtySkus[] = $sku;
        echo "<pre>";print_r($negativeSalableQtySkus);die;

You can check the array '$negativeSalableQtySkus', it will contain the skus of -ve salable qtys.

Please ignore the use of ObjectManagers you can use the same by injecting dependencies in constructor

  • Sorry I have no idea how to implement this I am still learning. Could you point me in the right direction. @Mohd
    – Shaun
    Apr 7, 2022 at 4:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.