I'm looking for a way to get current URL from the file "view.phtml". I've tried these 2 differents ways. None of them do print the entire product URL. Worst, the second way crashes...

/*1*/ Mage::log(__METHOD__ . '()'.Mage::getUrl('*/*/*'));
/*2*/ Mage::log(__METHOD__ . '()'.Mage::helper('core/url')->getCurrentUrl());

Don't hesitate to provide code snippets as I'm new in Magento.

  • If you're needing to sniff the current URL you have defined a solution to a problem that either shouldn't exist or you're approaching incorrectly. Often these can be solved by understanding how layout and layout handles work.
    – philwinkle
    Mar 9, 2015 at 20:59
  • Do you know any good tutorial to suggest me ?
    – jolyqr
    Mar 10, 2015 at 9:03

3 Answers 3


You may want to look into Mage::app()->getRequest() as well.


Also need to take note you're on a 4 year old Magento version. So things you read now can possibly be since a newer version.

Mage::app()->getRequest()->getRequestUri() should provide the correct url.


The following prints out current product URL. This code should be inserted in template/catalog/product/view.phtml


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.