0

i would like to change logic visibility:status i want logic work like this

if any simple(child)product has qty > 0 Show product status in stock else show out of stock. My code is app/design/frontend/default/mythem/template/catalog/product/view/type/default.phtml

   <?php $_product = $this->getProduct() ?>
<div class="available_price">
    <?php if ($this->displayProductStockStatus()): ?>   
    <?php if((int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty() > 0): ?>
            <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; ?>
    <?php endif; ?>

it logic working but issue is if configurable product has qty > 0 show out of stock.

i want this logic just work for simple(child products)

1 Answer 1

0

You can put product type condition with your qty check condition like,

<?php if($_product->isSalable()) : ?>  

This will display only simple products which has qty>0 as in stock.

9
  • thansk bro Your condition is right but when find in configurable product QTY is 0 it show out of stock Feb 22, 2017 at 9:39
  • If configurable product QTY is 0, then you want to show in stock or out of stock? Feb 22, 2017 at 9:50
  • I want this condition target only simple(child) products like this if any child product have qty > 0 that show in-stock Feb 22, 2017 at 10:00
  • and if no any qty in simple child products that should be show out of stock Feb 22, 2017 at 10:02
  • now issue is some parents(configurable) products have qty > 0 and some parents(configurable) products have qty == 0 Feb 22, 2017 at 10:05

Your Answer

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

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