10/25/2010

How to get Special price or Regular Price in magento

To get Special Price or Regular Price of a product you need to Know the product Id.
Then write the code Below to fetch the All Price of a procduct

<?php
$product= Mage::getModel('catalog/product')->load(product_id);
$price = $product->getPrice();
$webprice = $product->getwebprice();
$specialprice = $product->getFinalPrice();
if($specialprice==$price)
{?>
<span class="price">Price $<?php echo number_format($price,2);?></span>
<?php } else { ?>
<div class="regular-price">
<span>Regular Price:</span>
<span class="price">$ <?php echo number_format($price,2); ?></span>
</div>
<div class="special-price">
<span>Web Special:</span>
<span class="price">$ <?php echo number_format($specialprice,2); ?> </span>
</div>
<?php } ?>

2 comments:

  1. very helpful tutorial..it worked for me

    ReplyDelete
  2. Ok, get post but one quick question. What if I wanted to use this on the shopping cart page and have it reference each item in the cart and display the prices for each? How do I pull the item id for each item? Make sense?

    ReplyDelete