En los templates:
 $this->getRequest()- $this->getRequest()->getRouteName();
- $this->getRequest()->getModuleName();
- $this->getRequest()->getControllerName();
- $this->getRequest()->getActionName();
En cualquier clase, llamar de manera estática:
 Mage::app()- Mage::app()->getRequest()->getRouteName();
- Mage::app()->getRequest()->getModuleName();
- Mage::app()->getRequest()->getControllerName();
- Mage::app()->getRequest()->getActionName();
Todas las clases de arriba están presentes en la clase Mage_Core_Model_Url.
Para explorar todos los request:
echo '<pre>';
    print_r(Mage::app()->getRequest());
echo '</pre>';
El resultado se puede ver más o menos así:
Mage_Core_Controller_Request_Http Object
(
    [_originalPathInfo:protected] => /checkout/cart/
    [_storeCode:protected] => default
    [_requestString:protected] => /checkout/cart/
    [_rewritedPathInfo:protected] => 
    [_requestedRouteName:protected] => 
    [_route:protected] => checkout
    [_directFrontNames:protected] => Array
        (
            [api] => 
        )
    [_controllerModule:protected] => Mage_Checkout
    [_isStraight:protected] => 
    [_beforeForwardInfo:protected] => Array
        (
        )
    [_paramSources:protected] => Array
        (
            [0] => _GET
            [1] => _POST
        )
    [_requestUri:protected] => /checkout/cart/
    [_baseUrl:protected] => 
    [_basePath:protected] => 
    [_pathInfo:protected] => /checkout/cart/
    [_params:protected] => Array
        (
        )
    [_rawBody:protected] => 
    [_aliases:protected] => Array
        (
        )
    [_dispatched:protected] => 1
    [_module:protected] => checkout
    [_moduleKey:protected] => module
    [_controller:protected] => cart
    [_controllerKey:protected] => controller
    [_action:protected] => index
    [_actionKey:protected] => action
)
Artículo original:
http://blog.chapagain.com.np/magento-how-to-get-controller-action-and-module-name-in-template-file/
Autor: Mukesh Chapagain
 
 

No hay comentarios:
Publicar un comentario