0
app/design/frontend/vagwan/moto/Magento_GroupedProduct/templates/product/view/type/grouped.phtml

How Can I display price sum of associated products in Grouped Product in product page view ? I ve tried this code but is not working.

                <tr>
                <?php
                $all = $block->getAssociatedProducts($block->getProductPrice($_item));

                if ($_associatedProducts) {

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

                ?>
                <?php echo $priceForAll ?>
            </tr>

1 Answer 1

0

Please try

    <?php if ($_hasAssociatedProducts) : ?>
       <tr>
            <?php
            $priceForAll = 0;
            if ($_associatedProducts) {
                foreach ($_associatedProducts as $_item) {
                    $priceForAll += $block->getProductPrice($_item);
                }
            }
            ?>
            <?php echo $priceForAll ?>
        </tr>
     <?php endif; ?>

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.