Show Grouped product price in catalog view as sum of associated products in grouped product












0















In my magento store majority of products are "grouped products". Right now when you go in category you can see the label under the product image says "Price starting at" and the lower price of two associated products.



For example if one associated product cost $150 and the second $210, so the price in category view will be displayed as "Price starting at - $150".



In my case I want that the grouped product price would be displayed as the sum of two associated products without any labels like "Price starting at".



It should be displayed as a sum which in this case equal to "$360".



I hope someone could help me to find the solution.










share|improve this question


















  • 1





    For your requirement you need to customized magento functionality.

    – Dhiren Vasoya
    Dec 19 '16 at 13:32











  • Maybe you know what exactly?

    – Tautvydas Banys
    Dec 20 '16 at 0:56











  • Have you try any thing for this?

    – Dhiren Vasoya
    Dec 20 '16 at 3:04
















0















In my magento store majority of products are "grouped products". Right now when you go in category you can see the label under the product image says "Price starting at" and the lower price of two associated products.



For example if one associated product cost $150 and the second $210, so the price in category view will be displayed as "Price starting at - $150".



In my case I want that the grouped product price would be displayed as the sum of two associated products without any labels like "Price starting at".



It should be displayed as a sum which in this case equal to "$360".



I hope someone could help me to find the solution.










share|improve this question


















  • 1





    For your requirement you need to customized magento functionality.

    – Dhiren Vasoya
    Dec 19 '16 at 13:32











  • Maybe you know what exactly?

    – Tautvydas Banys
    Dec 20 '16 at 0:56











  • Have you try any thing for this?

    – Dhiren Vasoya
    Dec 20 '16 at 3:04














0












0








0








In my magento store majority of products are "grouped products". Right now when you go in category you can see the label under the product image says "Price starting at" and the lower price of two associated products.



For example if one associated product cost $150 and the second $210, so the price in category view will be displayed as "Price starting at - $150".



In my case I want that the grouped product price would be displayed as the sum of two associated products without any labels like "Price starting at".



It should be displayed as a sum which in this case equal to "$360".



I hope someone could help me to find the solution.










share|improve this question














In my magento store majority of products are "grouped products". Right now when you go in category you can see the label under the product image says "Price starting at" and the lower price of two associated products.



For example if one associated product cost $150 and the second $210, so the price in category view will be displayed as "Price starting at - $150".



In my case I want that the grouped product price would be displayed as the sum of two associated products without any labels like "Price starting at".



It should be displayed as a sum which in this case equal to "$360".



I hope someone could help me to find the solution.







magento2 price catalog-price-rules grouped-products






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 19 '16 at 13:28









Tautvydas BanysTautvydas Banys

64




64








  • 1





    For your requirement you need to customized magento functionality.

    – Dhiren Vasoya
    Dec 19 '16 at 13:32











  • Maybe you know what exactly?

    – Tautvydas Banys
    Dec 20 '16 at 0:56











  • Have you try any thing for this?

    – Dhiren Vasoya
    Dec 20 '16 at 3:04














  • 1





    For your requirement you need to customized magento functionality.

    – Dhiren Vasoya
    Dec 19 '16 at 13:32











  • Maybe you know what exactly?

    – Tautvydas Banys
    Dec 20 '16 at 0:56











  • Have you try any thing for this?

    – Dhiren Vasoya
    Dec 20 '16 at 3:04








1




1





For your requirement you need to customized magento functionality.

– Dhiren Vasoya
Dec 19 '16 at 13:32





For your requirement you need to customized magento functionality.

– Dhiren Vasoya
Dec 19 '16 at 13:32













Maybe you know what exactly?

– Tautvydas Banys
Dec 20 '16 at 0:56





Maybe you know what exactly?

– Tautvydas Banys
Dec 20 '16 at 0:56













Have you try any thing for this?

– Dhiren Vasoya
Dec 20 '16 at 3:04





Have you try any thing for this?

– Dhiren Vasoya
Dec 20 '16 at 3:04










2 Answers
2






active

oldest

votes


















4














I just had the same requirement. For a quick solution copy theme file



Magento_GroupedProducttemplatesproductpricefinal_price.phtml



to your custom theme and sum prices in template with



<?php

/*
* Show combined price instead of minimal price for grouped products.
*/

$products = $block->getSaleableItem()->getTypeInstance()->getAssociatedProducts($block->getSaleableItem());

$priceForAll = 0;
foreach ($products as $product) {
$priceForAll += $product->getPrice();
}

?>

<div class="price-box price-final_price" data-role="priceBox" data-product-id="284">
<span class="price-container price-final_price tax weee">
<span id="product-price-284" data-price-amount="<?php echo $priceForAll?>" data-price-type="finalPrice" class="price-wrapper ">
<span class="price"><?php echo number_format($priceForAll,2,',','.')?> €</span>
</span>
</span>
</div>


Please note that the final price formatting in html is a quick hack and just fits my requirements. A more felxible solution taking into account magento's price formatting features is welcome!






share|improve this answer


























  • Can you show all code in final_price.phtml file?

    – Tautvydas Banys
    Jan 6 '17 at 19:22











  • Edited the code snippet.

    – skymeissner
    Jan 9 '17 at 8:25





















0














I've refactored the code of @skymeissner:



<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

/**
* Template for displaying grouped product price
*/
?>
<?php
$allProducts = $block->getSaleableItem()->getTypeInstance()->getAssociatedProducts($block->getSaleableItem());
$priceHelper = $this->helper(MagentoFrameworkPricingHelperData::class);


if ($allProducts) {

$priceForAll = 0;
foreach ($allProducts as $product) {
$priceForAll += $product->getPrice();
}
}

?>

<div class="price-box" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<?php if ($priceForAll > 0 && MagentoFrameworkPricingRender::ZONE_ITEM_VIEW != $block->getZone()): ?>
<p class="grouped-price">
<span class="price-label">
<?= /* @escapeNotVerified */ __('Starting at') ?>
</span>
<span class="price">
<?= $formattedPrice = $priceHelper->currency($priceForAll, true, false); ?>
</span>
</p>
<?php endif ?>
</div>





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%2f150951%2fshow-grouped-product-price-in-catalog-view-as-sum-of-associated-products-in-grou%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4














    I just had the same requirement. For a quick solution copy theme file



    Magento_GroupedProducttemplatesproductpricefinal_price.phtml



    to your custom theme and sum prices in template with



    <?php

    /*
    * Show combined price instead of minimal price for grouped products.
    */

    $products = $block->getSaleableItem()->getTypeInstance()->getAssociatedProducts($block->getSaleableItem());

    $priceForAll = 0;
    foreach ($products as $product) {
    $priceForAll += $product->getPrice();
    }

    ?>

    <div class="price-box price-final_price" data-role="priceBox" data-product-id="284">
    <span class="price-container price-final_price tax weee">
    <span id="product-price-284" data-price-amount="<?php echo $priceForAll?>" data-price-type="finalPrice" class="price-wrapper ">
    <span class="price"><?php echo number_format($priceForAll,2,',','.')?> €</span>
    </span>
    </span>
    </div>


    Please note that the final price formatting in html is a quick hack and just fits my requirements. A more felxible solution taking into account magento's price formatting features is welcome!






    share|improve this answer


























    • Can you show all code in final_price.phtml file?

      – Tautvydas Banys
      Jan 6 '17 at 19:22











    • Edited the code snippet.

      – skymeissner
      Jan 9 '17 at 8:25


















    4














    I just had the same requirement. For a quick solution copy theme file



    Magento_GroupedProducttemplatesproductpricefinal_price.phtml



    to your custom theme and sum prices in template with



    <?php

    /*
    * Show combined price instead of minimal price for grouped products.
    */

    $products = $block->getSaleableItem()->getTypeInstance()->getAssociatedProducts($block->getSaleableItem());

    $priceForAll = 0;
    foreach ($products as $product) {
    $priceForAll += $product->getPrice();
    }

    ?>

    <div class="price-box price-final_price" data-role="priceBox" data-product-id="284">
    <span class="price-container price-final_price tax weee">
    <span id="product-price-284" data-price-amount="<?php echo $priceForAll?>" data-price-type="finalPrice" class="price-wrapper ">
    <span class="price"><?php echo number_format($priceForAll,2,',','.')?> €</span>
    </span>
    </span>
    </div>


    Please note that the final price formatting in html is a quick hack and just fits my requirements. A more felxible solution taking into account magento's price formatting features is welcome!






    share|improve this answer


























    • Can you show all code in final_price.phtml file?

      – Tautvydas Banys
      Jan 6 '17 at 19:22











    • Edited the code snippet.

      – skymeissner
      Jan 9 '17 at 8:25
















    4












    4








    4







    I just had the same requirement. For a quick solution copy theme file



    Magento_GroupedProducttemplatesproductpricefinal_price.phtml



    to your custom theme and sum prices in template with



    <?php

    /*
    * Show combined price instead of minimal price for grouped products.
    */

    $products = $block->getSaleableItem()->getTypeInstance()->getAssociatedProducts($block->getSaleableItem());

    $priceForAll = 0;
    foreach ($products as $product) {
    $priceForAll += $product->getPrice();
    }

    ?>

    <div class="price-box price-final_price" data-role="priceBox" data-product-id="284">
    <span class="price-container price-final_price tax weee">
    <span id="product-price-284" data-price-amount="<?php echo $priceForAll?>" data-price-type="finalPrice" class="price-wrapper ">
    <span class="price"><?php echo number_format($priceForAll,2,',','.')?> €</span>
    </span>
    </span>
    </div>


    Please note that the final price formatting in html is a quick hack and just fits my requirements. A more felxible solution taking into account magento's price formatting features is welcome!






    share|improve this answer















    I just had the same requirement. For a quick solution copy theme file



    Magento_GroupedProducttemplatesproductpricefinal_price.phtml



    to your custom theme and sum prices in template with



    <?php

    /*
    * Show combined price instead of minimal price for grouped products.
    */

    $products = $block->getSaleableItem()->getTypeInstance()->getAssociatedProducts($block->getSaleableItem());

    $priceForAll = 0;
    foreach ($products as $product) {
    $priceForAll += $product->getPrice();
    }

    ?>

    <div class="price-box price-final_price" data-role="priceBox" data-product-id="284">
    <span class="price-container price-final_price tax weee">
    <span id="product-price-284" data-price-amount="<?php echo $priceForAll?>" data-price-type="finalPrice" class="price-wrapper ">
    <span class="price"><?php echo number_format($priceForAll,2,',','.')?> €</span>
    </span>
    </span>
    </div>


    Please note that the final price formatting in html is a quick hack and just fits my requirements. A more felxible solution taking into account magento's price formatting features is welcome!







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jan 9 '17 at 8:25

























    answered Dec 30 '16 at 16:02









    skymeissnerskymeissner

    13810




    13810













    • Can you show all code in final_price.phtml file?

      – Tautvydas Banys
      Jan 6 '17 at 19:22











    • Edited the code snippet.

      – skymeissner
      Jan 9 '17 at 8:25





















    • Can you show all code in final_price.phtml file?

      – Tautvydas Banys
      Jan 6 '17 at 19:22











    • Edited the code snippet.

      – skymeissner
      Jan 9 '17 at 8:25



















    Can you show all code in final_price.phtml file?

    – Tautvydas Banys
    Jan 6 '17 at 19:22





    Can you show all code in final_price.phtml file?

    – Tautvydas Banys
    Jan 6 '17 at 19:22













    Edited the code snippet.

    – skymeissner
    Jan 9 '17 at 8:25







    Edited the code snippet.

    – skymeissner
    Jan 9 '17 at 8:25















    0














    I've refactored the code of @skymeissner:



    <?php
    /**
    * Copyright © Magento, Inc. All rights reserved.
    * See COPYING.txt for license details.
    */

    // @codingStandardsIgnoreFile

    /**
    * Template for displaying grouped product price
    */
    ?>
    <?php
    $allProducts = $block->getSaleableItem()->getTypeInstance()->getAssociatedProducts($block->getSaleableItem());
    $priceHelper = $this->helper(MagentoFrameworkPricingHelperData::class);


    if ($allProducts) {

    $priceForAll = 0;
    foreach ($allProducts as $product) {
    $priceForAll += $product->getPrice();
    }
    }

    ?>

    <div class="price-box" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
    <?php if ($priceForAll > 0 && MagentoFrameworkPricingRender::ZONE_ITEM_VIEW != $block->getZone()): ?>
    <p class="grouped-price">
    <span class="price-label">
    <?= /* @escapeNotVerified */ __('Starting at') ?>
    </span>
    <span class="price">
    <?= $formattedPrice = $priceHelper->currency($priceForAll, true, false); ?>
    </span>
    </p>
    <?php endif ?>
    </div>





    share|improve this answer




























      0














      I've refactored the code of @skymeissner:



      <?php
      /**
      * Copyright © Magento, Inc. All rights reserved.
      * See COPYING.txt for license details.
      */

      // @codingStandardsIgnoreFile

      /**
      * Template for displaying grouped product price
      */
      ?>
      <?php
      $allProducts = $block->getSaleableItem()->getTypeInstance()->getAssociatedProducts($block->getSaleableItem());
      $priceHelper = $this->helper(MagentoFrameworkPricingHelperData::class);


      if ($allProducts) {

      $priceForAll = 0;
      foreach ($allProducts as $product) {
      $priceForAll += $product->getPrice();
      }
      }

      ?>

      <div class="price-box" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
      <?php if ($priceForAll > 0 && MagentoFrameworkPricingRender::ZONE_ITEM_VIEW != $block->getZone()): ?>
      <p class="grouped-price">
      <span class="price-label">
      <?= /* @escapeNotVerified */ __('Starting at') ?>
      </span>
      <span class="price">
      <?= $formattedPrice = $priceHelper->currency($priceForAll, true, false); ?>
      </span>
      </p>
      <?php endif ?>
      </div>





      share|improve this answer


























        0












        0








        0







        I've refactored the code of @skymeissner:



        <?php
        /**
        * Copyright © Magento, Inc. All rights reserved.
        * See COPYING.txt for license details.
        */

        // @codingStandardsIgnoreFile

        /**
        * Template for displaying grouped product price
        */
        ?>
        <?php
        $allProducts = $block->getSaleableItem()->getTypeInstance()->getAssociatedProducts($block->getSaleableItem());
        $priceHelper = $this->helper(MagentoFrameworkPricingHelperData::class);


        if ($allProducts) {

        $priceForAll = 0;
        foreach ($allProducts as $product) {
        $priceForAll += $product->getPrice();
        }
        }

        ?>

        <div class="price-box" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
        <?php if ($priceForAll > 0 && MagentoFrameworkPricingRender::ZONE_ITEM_VIEW != $block->getZone()): ?>
        <p class="grouped-price">
        <span class="price-label">
        <?= /* @escapeNotVerified */ __('Starting at') ?>
        </span>
        <span class="price">
        <?= $formattedPrice = $priceHelper->currency($priceForAll, true, false); ?>
        </span>
        </p>
        <?php endif ?>
        </div>





        share|improve this answer













        I've refactored the code of @skymeissner:



        <?php
        /**
        * Copyright © Magento, Inc. All rights reserved.
        * See COPYING.txt for license details.
        */

        // @codingStandardsIgnoreFile

        /**
        * Template for displaying grouped product price
        */
        ?>
        <?php
        $allProducts = $block->getSaleableItem()->getTypeInstance()->getAssociatedProducts($block->getSaleableItem());
        $priceHelper = $this->helper(MagentoFrameworkPricingHelperData::class);


        if ($allProducts) {

        $priceForAll = 0;
        foreach ($allProducts as $product) {
        $priceForAll += $product->getPrice();
        }
        }

        ?>

        <div class="price-box" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
        <?php if ($priceForAll > 0 && MagentoFrameworkPricingRender::ZONE_ITEM_VIEW != $block->getZone()): ?>
        <p class="grouped-price">
        <span class="price-label">
        <?= /* @escapeNotVerified */ __('Starting at') ?>
        </span>
        <span class="price">
        <?= $formattedPrice = $priceHelper->currency($priceForAll, true, false); ?>
        </span>
        </p>
        <?php endif ?>
        </div>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 21 mins ago









        Stevie-Ray HartogStevie-Ray Hartog

        134




        134






























            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%2f150951%2fshow-grouped-product-price-in-catalog-view-as-sum-of-associated-products-in-grou%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