1

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.

3 Answers 3

2

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's catalog, you'll find the controller in app\code\core\Mage\Catalog\controllers

  • controller is a php file inside modules controller folder, in this case ProductController.php

  • action is a method inside this controller file, like viewAction()

2

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

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.