Question

I Used below code Observer called but can not redirect to admin product page.

path: local/Package1/Test1/etc/config.xml

 <adminhtml>
    <events>
       <controller_action_layout_generate_blocks_before>
                <observers>
                    <module_block_observer>
                        <type>singleton</type>
                        <class>test1/observer</class>
                        <method>testredirect</method>
                    </module_block_observer>
                </observers>
        </controller_action_layout_generate_blocks_before>
    </events>
 <adminhtml>

path: local/Package1/Test1/Model/Observer.php

public function testredirect($observer)
{
  $url = Mage::helper("adminhtml")->getUrl("adminhtml/catalog_product/index/");

        Mage::app()->getFrontController()->getResponse()->setRedirect($url);
        Mage::app()->getResponse()->sendResponse();
}

I want to redirect to admin catalog product page('product grid page') using observer but my redirect code does not work and browser throw error. Error is This webpage has a redirect loop ERR_TOO_MANY_REDIRECTS

Was it helpful?

Solution

Your redirect works.
The problem is that each time you access a page it redirects to adminhtml/catalog_product/index/ and then, when loading this page, it redirects to adminhtml/catalog_product/index/ and then, when loading this page, it redirects to adminhtml/catalog_product/index/ and then.....

You need a case when you should not redirect anymore.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top