Show product price in Magento

Posted on 2012-08-31
Last Modified: 2012-08-31
Hi guys,

I have a small problem which has taken me several hours of searching and I still cannot solve the issue.

I have a product category left-sidebar which displays thumbnails of products and a link to vew the item.

I am trying to also include the price and quantity available in stock but I firs need to get the price to show.

<?php echo $this->getPriceHtml($_product) ?>

Open in new window

The code isn't outputting the price.

Here is the entire code for sidebarCategories.phtml

$category_id = "36"; // category_id for "Featured Products"
$_productCollection = Mage::getResourceModel('catalog/product_collection')
  ->addAttributeToSelect(array('name', 'price', 'small_image'), 'inner')
<?php if($_productCollection->count()): ?>
<div class="block block-featured-product">
  <div class="block-title">
    <strong>Featured Products</strong>
  <div class="block-content">

    <ul id="featured-product-list">

  $products = array();
  foreach ($_productCollection as $_product) { 
      <li class="featured-product">
          <strong><?php echo $this->htmlEscape($_product->getName())?></strong><?php echo $this->getPriceHtml($_product) ?><br />
          <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>">
            <img class="product-image" src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(107, 107); ?>" alt="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" />
<a class="view-item-button" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>">View Item</a>
      <hr />
<?php } ?>
<?php endif; ?>

Open in new window

Question by:rafique12
    LVL 42

    Expert Comment

    by:Chris Stanyon
    Try these functions instead:

    echo $_product->getPrice();
    echo $_product->getSpecialPrice();
    echo $_product->getFinalPrice();

    Author Comment

    Thankyou for your help!

    Is there a way to show currency symbol as the store has three different currencies?
    LVL 42

    Accepted Solution

    Something like this should do it:

     echo Mage::helper('core')->currency($_product->getPrice());

    Featured Post

    Courses: Start Training Online With Pros, Today

    Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

    Join & Write a Comment

    Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
    Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now