Magento 1.9 How to find the physical file location from $this->geturl
-
09-10-2020 - |
Question
In Magento, I often see this code from different modules. for example
'url' = $this->geturl('*/path/to/file',array('_forced_secure' => $this->getRequest()->isSecure()))
But how can I find out which file on the server is being called from geturl? the path given in the code is not the physical path to the file.
Solution
Instead of path/to/file
take a look at this:
$this->geturl('module/controller/action')
or
$this->geturl('catalog/product/view')
module
gives you a first hint, where to search. For expample if it'scatalog
, you'll find the controller inapp\code\core\Mage\Catalog\controllers
controller
is a php file inside modules controller folder, in this caseProductController.php
action
is a method inside this controller file, likeviewAction()
OTHER TIPS
From getUrl
Magento call a particular action of a module's controller. the syntax in function is like getUrl('modulename/controller/action')
for example if you use getUrl('customer/account/create')
then it will call Customer module's AccountController.php
file and in this file it call createAction
function.
To locate file you have to go to app/code/CodePool/Namespace/ModuleName/controllers/
for the given example of customer/account/create
you will find the file at app/code/core/Mage/Customer/controllers/AccountController.php
Inside app/Mage.php
public static function getUrl($route = '', $params = array())
{
return self::getModel('core/url')->getUrl($route, $params);
}
Which in turns go inside app\code\core\Mage\Core\Model\Url.php
and call getUrl().
And you need to pass frontname/controllerName/actionName
not modulename
. frontname
gets defined inside config.xml
for any module.