Si estas en un plugind usas el hook OutputHTMLBefore
public function hookActionOutputHTMLBefore($params)
{
$controller = $this->context->controller;
if (
!$this->context->customer->isLogged()
&& $controller->php_self != ‘authentication’ &&
$controller->php_self != ‘password’
&& $controller->php_self != ‘cms’ &&
$controller->php_self != ‘contact’)
{
Tools::redirect(‘index.php?controller=authentication?back=my-account’);
}
}
Si no en el controllador controller/front/FrontController insertas la sentencia if en la funcion init() justo despues de parent::init;
Hay que tener en cuenta que si lo quieres hacer update safe hay que sobre escribir el controlador en la carpeta overrides
public function init()
{
/*
* Globals are DEPRECATED as of version 1.5.0.1
* Use the Context object to access objects instead.
* Example: $this->context->cart
*/
global $useSSL, $cookie, $smarty, $cart, $iso, $defaultCountry, $protocol_link, $protocol_content, $link, $css_files, $js_files, $currency;
if (self::$initialized) {
return;
}
self::$initialized = true;
parent::init();
if (
!$this->context->customer->isLogged()
&& $this->php_self != ‘authentication’
&& $this->php_self != ‘password’
&& $this->php_self != ‘cms’
&& $this->php_self != ‘contact’)
{
Tools::redirect(‘index.php?controller=authentication?back=my-account’);
}
….