2

Magento 1.9 Community. Im trying to show a "From" next to price of configurable products in category/product view page. My template "Milano" has a file list.phtml for categories and i have changed the code to the following :

<?php if ($_product->isConfigurable()) { ?>
                        <div style="float:left;"><?php echo $this->__('From ') ?></div><?php echo $this->getPriceHtml($_product, true) ?>
                    <?php } else { ?>
                    <?php echo $this->getPriceHtml($_product, true) ?>
                    <?php } ?>

The problem is that the "from" is also visible to configurable products that they don't have different prices. I also used the next code that checks min and max

$childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null,$_product);
                    $childPriceLowest = "";    
                    $childPriceHighest = "";       
                    foreach($childProducts as $child){
                        $_child = Mage::getModel('catalog/product')->load($child->getId());

                        if($childPriceLowest == '' || $childPriceLowest > $_child->getPrice() )
                        $childPriceLowest =  $_child->getPrice();

                        if($childPriceHighest == '' || $childPriceHighest < $_child->getPrice() )
                        $childPriceHighest =  $_child->getPrice();

and added a the end the if childpricelowest = childpricehighest then show only price but the page goes white screen.

Perhaps someone can put the together correctly or give another solution?

3
  • If you have a black screen, you certainly have a fatal error. Can you show us the apache logs and magento logs, please ?
    – Pilou
    Commented Mar 18, 2015 at 15:51
  • Open index.php and enable developermode() to directly see what's wrong and start debugging from there
    – Jeroen
    Commented Mar 19, 2015 at 22:58
  • It might be because you iterate through $childProducts and get $child, but you use $_child in the foreach body.
    – mimarcel
    Commented Mar 20, 2015 at 14:13

1 Answer 1

0

I upgrade your code and testing. It's work

                    <?php if($_product->isConfigurable()) {

                        $childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null,$_product);
                        $childPriceLowest = "";    
                        $childPriceHighest = "";  
                        $priceLowest = Array();

                            foreach ($childProducts as $child): ?>
                                <?php 
                                $_child = Mage::getModel('catalog/product')->load($child->getId());

                                if($childPriceLowest == '' || $childPriceLowest > $_child->getPrice() )
                                $childPriceLowest =  $_child->getFinalPrice();
                                $priceLowest[] = $childPriceLowest;

                                if($childPriceHighest == '' || $childPriceHighest < $_child->getPrice() )
                                $childPriceHighest =  $_child->getPrice(); ?>

                            <?php endforeach; ?>

                    <?php echo '<pre>'; print_r(min($priceLowest)); echo '</pre>'; ?>

                    <?php  }   ?>

Print only most lowest price of product's children

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.