While I was working on a module , it was required to redirect to a particular page,I tried to using header('lcoation')... .But it was not worked,So I searched in net How to redirect from a controller to product page, No solution Found .i tried myself and got a solution ,Which I am posting here.
In my controller i was sending the product Id and After doing some work I need to redirect to that product page.
I got this solution and worked.
$productId=$this->getRequest()->getParam('productId');
$obj = Mage::getModel('catalog/product');
$_product = $obj->load($productId);
$prdurl=$_product->getProductUrl();
$url=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
$_prdurl=explode($url,$prdurl);
$this->_redirect($_prdurl[1]);
No comments:
Post a Comment