[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Show product price in Magento

Posted on 2012-08-31
3
Medium Priority
?
991 Views
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

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

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

 <?php 
  $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>
      </li>
<a class="view-item-button" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>">View Item</a>
      <hr />
<?php } ?>
    </ul>
  </div>
</div>
<?php endif; ?>

Open in new window

0
Comment
Question by:rafique12
  • 2
3 Comments
 
LVL 45

Expert Comment

by:Chris Stanyon
ID: 38353797
Try these functions instead:

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

Author Comment

by:rafique12
ID: 38353962
Thankyou for your help!

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

Accepted Solution

by:
Chris Stanyon earned 2000 total points
ID: 38354051
Something like this should do it:

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

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses
Course of the Month18 days, 22 hours left to enroll

834 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