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?


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 | |

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
   //  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.