Magento 1.9 – How to Show Price from Product

magento-1.9PHPpriceproduct

On the homepage i have categories with description and 2 latest added products from that specific category.

Now i have it working to display 2 products per category with image and productname but i can't get it working to show the product price also.

This is my code now:

<?php
    $_categoryId = explode(' ', $category['id']);

    $count = 0;

    $_productCollection = Mage::getModel('catalog/category')->load($_categoryId)
        ->getProductCollection()
        ->addAttributeToSelect('*')
        ->setOrder('date_added', 'ASC');
    ?>

    <?php foreach ($_productCollection as $_product): ?>

        <?php
            $count++; // Note that first iteration is $count = 1 not 0 here.
            if($count <= 3) continue; // Skip the iteration unless 4th or above.
        ?>

        <li class="category-row-list-item">

            <a class="product-name" href="<?php echo $_product->getProductUrl() ?>">
                <?php echo $this->htmlEscape($_product->getName()) ?>
            </a>

        </li>
        <?php
            if($count == 6) break;
        ?>
    <?php endforeach ?>

Best Answer

Add this code for price where you want to display it.

echo Mage::helper('checkout')->formatPrice($_product->getFinalPrice());

Related Topic