0
votes

I got a problem while trying to change a value in stock availability in product list. I attach my code, where i tried to make a new if-option, in which i am trying to check the qty of a product in database and if it is exactly the price i want to, then it enters the first and right "if" and shows the right message.

Thanks for your help.

<?php if ($this->displayProductStockStatus()): ?>
    <?php if ($_product['Qty']==1234): ?>
        <p class="availability in-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('Available in 2-5 days') ?></span></p>
    <?php elseif ($_product->isAvailable()): ?>
        <p class="availability in-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('In stock') ?></span></p>
    <?php else: ?>
        <p class="availability out-of-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('Out of stock') ?></span></p>
    <?php endif; ?>

File : app\design\frontend\base\default\template\catalog\product\view\type\default.phtml

1

1 Answers

0
votes

Try:

$_product->getStockItem()->getQty();

or

$stock = Mage::getModel('cataloginventory/stock_item')
                ->loadByProduct($_product)->getQty();