2

I need different price formatting on list view and product view but both views use the same template template\catalog\product\price.phtml to display the price. Is there a way to distinguish if list view or product view is calling the template?

2

Yes you can use the following two to distinguish

Calling the following

<?php if (Mage::registry('current_category')) { ?>
     then show this price
<?php }else if(Mage::registry('current_product')) {?>
    show this price
<?php } ?>

will either return null if the objects haven't been set (i.e. you're on a page without a category or a product), or return category and product objects.

If a product object is returned you're on a product page.

| improve this answer | |
1

To distinguish the price on list view and product view, you can use the following :

<?php if(Mage::app()->getFrontController()->getRequest()->getControllerName() == 'product')
{ 
    // price formatting for product view page
}
else
{
   //  price formatting for product list page
}
?>
| improve this answer | |

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.