3

Anyone know how to remove the "Only # left" from showing on the product page of the store?

System > Configuration > Inventory for Stock Options has the field "Only X left Threshold" set to "0" which is suppose to disable this yet it still shows. I've also set Manage Stock to No for Product Stock Options. I've done the obvious with clearing cache. I'm running 1.8 ver and to have a Custom Theme installed. Is this a known bug or could the Custom Theme be overriding something?

2
  • 1
    Check the Product page of your theme, there might be the issue.
    – mbalparda
    Commented Jul 18, 2014 at 14:10
  • Did you reindex the cataloginventory_stock index after disabling the stock management?
    – Thorsten
    Commented Jul 18, 2014 at 14:13

5 Answers 5

2

in the file

app\design\frontend\default\YourTheme\template\catalog\product

the following lines need to be changed.

        <div class="availability-only">
            <?php echo $this->__('Only') ?> 
            <?php echo (int)($qtyStock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty());?>
            <?php echo $this->__('left') ?>
        </div>

Add the first line and the last line. The finished code should look like this:

        <?php if ($this->displayProductStockStatus()): ?>
            <div class="availability-only">
                <?php echo $this->__('Only') ?> 
                <?php echo (int)($qtyStock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty());?>
                <?php echo $this->__('left') ?>
            </div>
        <?php endif; ?> 
2

The easiest way to disable this message in Magento 2 is to just set the threshold to -1 under Stores > Settings > Configuration > Catalog > Inventory > Stock Options > Only X left Threshold.

1

So in Magento 1.9 this section is added using the following files.

  1. app/design/frontend/base/default/template/cataloginventory/stockqty/composite.phtml
  2. app/design/frontend/base/default/template/cataloginventory/stockqty/default.phtml

These files are added from the layout xml file app/design/frontend/base/default/layout/cataloginventory.xml. The default file is for simple and virtual products and the composite is for grouped, bundle and configurable products.

Each of these templates use the function isMsgVisible before showing the message.

public function isMsgVisible()
{
    return ($this->getStockQty() > 0 && $this->getStockQty() <= $this->getThresholdQty());
}

So I think if you simply set the threshold quantity to 0 then the message will not show up. If you need the threshold but no message then what you can do is on of the follow.

  1. Make a version of these files in your theme and remove the information,
  2. Remove the blocks via a layout.xml change,
  3. Rewrite the blocks and extend the function isMsgVisible,

For me I would go with either the setting of the threshold to 0 or unsetting the blocks via a layout xml.

1

You have to disable "Display products availability in stock in the frontend" in System -> Configuration -> Inventory too.

0

In the file app\code\core\Mage\CatalogInventory\Block\Stockqty\Abstract.php I changed

public function isMsgVisible()
{
   return ($this->getStockQty() > 0 && $this->getStockQty() <= $this->getThresholdQty());
}

I change to

public function isMsgVisible()
{

   return false;
}

Its working to me. Hope it help.

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.