Configurable products Show “From” next to price in category/product page












1















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?










share|improve this question














bumped to the homepage by Community 13 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • If you have a black screen, you certainly have a fatal error. Can you show us the apache logs and magento logs, please ?

    – Pilou
    Mar 18 '15 at 15:51











  • Open index.php and enable developermode() to directly see what's wrong and start debugging from there

    – Jeroen
    Mar 19 '15 at 22:58











  • It might be because you iterate through $childProducts and get $child, but you use $_child in the foreach body.

    – mimarcel
    Mar 20 '15 at 14:13
















1















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?










share|improve this question














bumped to the homepage by Community 13 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • If you have a black screen, you certainly have a fatal error. Can you show us the apache logs and magento logs, please ?

    – Pilou
    Mar 18 '15 at 15:51











  • Open index.php and enable developermode() to directly see what's wrong and start debugging from there

    – Jeroen
    Mar 19 '15 at 22:58











  • It might be because you iterate through $childProducts and get $child, but you use $_child in the foreach body.

    – mimarcel
    Mar 20 '15 at 14:13














1












1








1


1






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?










share|improve this question














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?







magento-1.9 configurable-product






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 18 '15 at 15:35









GeorgeVGeorgeV

94




94





bumped to the homepage by Community 13 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 13 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • If you have a black screen, you certainly have a fatal error. Can you show us the apache logs and magento logs, please ?

    – Pilou
    Mar 18 '15 at 15:51











  • Open index.php and enable developermode() to directly see what's wrong and start debugging from there

    – Jeroen
    Mar 19 '15 at 22:58











  • It might be because you iterate through $childProducts and get $child, but you use $_child in the foreach body.

    – mimarcel
    Mar 20 '15 at 14:13



















  • If you have a black screen, you certainly have a fatal error. Can you show us the apache logs and magento logs, please ?

    – Pilou
    Mar 18 '15 at 15:51











  • Open index.php and enable developermode() to directly see what's wrong and start debugging from there

    – Jeroen
    Mar 19 '15 at 22:58











  • It might be because you iterate through $childProducts and get $child, but you use $_child in the foreach body.

    – mimarcel
    Mar 20 '15 at 14:13

















If you have a black screen, you certainly have a fatal error. Can you show us the apache logs and magento logs, please ?

– Pilou
Mar 18 '15 at 15:51





If you have a black screen, you certainly have a fatal error. Can you show us the apache logs and magento logs, please ?

– Pilou
Mar 18 '15 at 15:51













Open index.php and enable developermode() to directly see what's wrong and start debugging from there

– Jeroen
Mar 19 '15 at 22:58





Open index.php and enable developermode() to directly see what's wrong and start debugging from there

– Jeroen
Mar 19 '15 at 22:58













It might be because you iterate through $childProducts and get $child, but you use $_child in the foreach body.

– mimarcel
Mar 20 '15 at 14:13





It might be because you iterate through $childProducts and get $child, but you use $_child in the foreach body.

– mimarcel
Mar 20 '15 at 14:13










1 Answer
1






active

oldest

votes


















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






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "479"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f61258%2fconfigurable-products-show-from-next-to-price-in-category-product-page%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    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






    share|improve this answer




























      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






      share|improve this answer


























        0












        0








        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






        share|improve this answer













        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







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Sep 12 '17 at 8:42









        yavonz15yavonz15

        146216




        146216






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f61258%2fconfigurable-products-show-from-next-to-price-in-category-product-page%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Magento 2 controller redirect on button click in phtml file

            Polycentropodidae