Question

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!

Was it helpful?

Solution

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());

OTHER TIPS

try below

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

Or

 Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getBaseUrl());
exit();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top