How to print out current url on Magento 1.4.1.1?
-
12-12-2019 - |
Question
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.
Solution
You may want to look into Mage::app()->getRequest() as well.
OTHER TIPS
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
$this->helper('core/url')->getCurrentUrl();
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange