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.

Était-ce utile?

La 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'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()

Autres conseils

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange
scroll top