1

I need use the (final)product price for calculation purposes on the category page. In the category template file the price is loaded through the method:

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

This returns HTML output like: "Your price is: $4,00". I'm using a combination of (normal) prices, special prices and tier prices. What I basically need is the price so I can make calculations with a another attribute.

I've been looking at a solution where I'm extending block functionality to just return the final prices. Until now I've failed to construct something that actually works.

Thanks!

1

There are several different ways of getting prices in Magento. getPriceHtml will output the full HTML markup for the price, as you've demonstrated in your answer.

Other methods of showing the price are below:

Getting the Price without Currency Formatting

$_product->getPrice(); // Regular price, without currency
$_product->getFinalPrice(); // Final Price, without currency
$_product->getMsrp(); // MSRP, without currency

Getting the Price with Currency Formatting

$_coreHelper->currency($_product->getPrice(), true, false); // Regular Price
$_coreHelper->currency($_product->getFinalPrice(), true, false); // Final Price
$_coreHelper->currency($_product->getMsrp(), true, false); // MSRP

An Example

Suppose you wanted to calculate the item's discount using the MSRP and Final Price, rounded up and outputted as an unformatted number:

$savingsCalculation = round(($_product->getMsrp() - $_product->getFinalPrice()) / $_product->getMsrp() * 100);
  • Thanks for your answer, it is however not working for me. We're working with tier pricing and none of these methode return that price. Our regular price is set for all products to 100.000.000 so $_product->getPrice(); will actually return this price. Any other ideas? – Badger Oct 11 '15 at 19:43

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.