For reference, Please install magento 2.3.0 instance with sample data and observe LifeLong Fitness IV product.

On product detail page, it's showing Out of Stock and it makes sense to me as quantity is 0 and it's not even using Advanced Inventory options as well for stock management.

How come it's showing Add to Cart button on home page/grid. when it is out of stock.

  • Also the Backorders options is set as No Backorders.

According to my research, I have figured out that isSalable() is returning true for this product because of the function getStatusExpression() in /var/www/html/magento2/vendor/magento/module-catalog-inventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php.

protected function getStatusExpression(AdapterInterface $connection, $isAggregate = false)
        $isInStockExpression = $isAggregate ? 'MAX(cisi.is_in_stock)' : 'cisi.is_in_stock';
        if ($this->_isManageStock()) {
            $statusExpr = $connection->getCheckSql(
                'cisi.use_config_manage_stock = 0 AND cisi.manage_stock = 0',
        } else {
            $statusExpr = $connection->getCheckSql(
                'cisi.use_config_manage_stock = 0 AND cisi.manage_stock = 1',
        return $statusExpr;

Basically what it does is that whenever indexing is performed, it sets stock_status of product by default as 1 for products not using Advanced inventory options.

The reason why we see Add to Cart for the mentioned product is because it sets stock_status as 1 and makes it saleable product even though it's quantity is 0.

Please check this tables for reference




If you set stock_staus manually in cataloginventory_stock_status as 0, it will not show Add to Cart button.

What I want is that I don't want to show Add to Cart button if the product is out of stock.

Please let me know if there is any configuration for it that I'm missing or it requires any customization on core files or if it's a magento bug.

  • 1
    I just figured out that I had my customizations on product detail page plus it's a downloadable product, so that is the reason why I could see the difference of product status on detail page and grids. But the question still remains that how can we programmatically change status of mass downloadable products to Out of Stock. – Sanjay Chaudhary Apr 17 '19 at 11:31

For reference, Please install magento 2.3.0 instance with sample data and observe LifeLong Fitness IV product.

I have checked the same product in Magento 2.3.1 and it is displaying in stock status.

The reason behind this is, Attribute set is Downloadable product, if you see admin panel while creating the downloadable product see below image ref. Salable Quantity have No manage stock status

enter image description here

And in front end it will require customers to get link only when they have already logged in, or you will send the download link via email and allow them to share with anyone needing.

enter image description here

| improve this answer | |
  • 1
    Thank you for your answer, but I still have a query that you can find in my comments. – Sanjay Chaudhary Apr 17 '19 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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