Frage

I am in catalog\product\compare\list.phtml and I want to redirect to the homepage, like this:

if($someThing) {
    // redirect to homepage
    $this->_redirect('home'); // --> doesnt work
    $this->_redirect(Mage::getBaseUrl()); // --> doesnt work
}

I tried several things, none worked so far. How do I do it right?

Thanks!

War es hilfreich?

Lösung

As far as I know the $this->_redirect can only be used in a controller.

Try this instead:

    Mage::app()->getFrontController()->getResponse()->setRedirect($this->getBaseUrl());

Andere Tipps

try below

header("Location:".Mage::getBaseUrl());
exit();

Or

 Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getBaseUrl());
exit();
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top