How can I call an action of my controller in a custom module after "Save Config" was clicked in System --> Configuration --> Catalog? (image)
Settings of my module are inside that section, and I need to fire my action just after configuration was saved. I need to call the action only in that section of the admin panel - if "Save Config" was clicked in a different section of the admin, the action don't need to be called.
EDIT:
Action has to check if saved settings of the module are correct, and do some other calculations every time the configuration is saved.
EDIT 2:
I tried solution posted by Fabian Blechschmidt. Observer is working after "Save Config" was clicked (I see text in log file):
config.xml:
<config>
...
<global>
<events>
<admin_system_config_changed_section_mysection>
<observers>
<mymodule>
<type>singleton</type>
<class>mymodule/observer</class>
<method>handle_adminSystemConfigChangedSection</method>
</mymodule>
</observers>
</admin_system_config_changed_section_mysection>
</events>
</global>
...
</config>
Model/Observer.php:
class My_Module_Model_Observer
{
public function handle_adminSystemConfigChangedSection()
{
Mage::log('Test: oberver is working!');
//I tried this but it doesn't actually trigger the action:
$url = Mage::getUrl('myrouter/adminhtml_test/validate');
Mage::app()->getResponse()->setRedirect($url);
}
}
But now I'm stuck.
I don't know how to trigger action method inside that observer. Controller looks like this and it works fine:
config.xml:
<admin>
<routers>
<mymodule>
<use>admin</use>
<args>
<module>My_Module</module>
<frontName>myrouter</frontName>
</args>
</mymodule>
</routers>
</admin>
controllers/Adminhtml/TestController.php:
class My_Module_Adminhtml_TestController extends Mage_Adminhtml_Controller_Action
{
public function validateAction()
{
//validate config settings here
}
}
EDIT 3:
Event-observer solution works fine, so I created separate question about redirecting to actions: Redirect to module/controller/action