문제

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!

도움이 되었습니까?

해결책

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

다른 팁

try below

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

Or

 Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getBaseUrl());
exit();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top