I'm newbie to Magento, I'm just testing product price module so by using following code

<?php echo Mage::helper('core')->currency($_product->getFinalPrice()); ?>

It return me price properly for Simple product but it's not working for Grouped product So I Googled it and found following code snippet

<?php echo $_product->getPrice(); ?>
<?php echo Mage::helper('core')->currency($_product->getPrice(),true,false); ?>
<?php echo $_product->getFinalPrice(); ?>
<?php echo Mage::helper('core')->currency($_product->getFinalPrice(),true,false); ?>
<?php echo Mage::helper('tax')->getPrice($_product, $_product->getFinalPrice(), true); ?>

But all above code return me price as 0 , So can please anybody suggest me what can I do to get price which work for both Simple & Grouped product?


Grouped Product is a combination of products, you can't directly call ->getPrice() on Grouped Products.

Use below code instead:

$product = Mage::getModel("catalog/product")->load(PRUDUCT_ID);

if($product -> getTypeId() == "grouped"){
    $grouped_product_model = Mage::getModel('catalog/product_type_grouped');
    $groupedParentId = $grouped_product_model->getParentIdsByChild($product->getId());
    $_associatedProducts = $product->getTypeInstance(true)->getAssociatedProducts($product);

    foreach($_associatedProducts as $_associatedProduct) {
        if($ogPrice = $_associatedProduct->getPrice()) {
            $ogPrice = $_associatedProduct->getPrice();

    $ogPrice = number_format((float)$ogPrice, 2, '.', '');
    echo $ogPrice;
    echo $_product->getFinalPrice();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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