0

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.

2
  • 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 '15 at 20:59
  • Do you know any good tutorial to suggest me ? – jolyqr Mar 10 '15 at 9:03
0

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

0
0

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.

0

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

$this->helper('core/url')->getCurrentUrl();

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.