It’s very easy to call an event after save of a “System / Config” page section.

In the config.xml of your module, add this code:

<?xml version="1.0"?>
<config>
    <!-- ... -->
	<adminhtml>
		<events>
			<admin_system_config_changed_section_SECTIONNAME>
				<observers>
					<NOM_DE_VOTRE_OBSERVER>
						<type>singleton</type>
						<class>NOM_DU_MODULE/observer</class>
						<method>adminSystemConfigChangedSECTIONNAME</method>
					</NOM_DE_VOTRE_OBSERVER>
				</observers>
			</admin_system_config_changed_section_SECTIONNAME>
		</events>
	</adminhtml>
	<!-- ... -->
</config>

And in your Observer :

<?php
class YOUR_MODULE_NAME_Model_Observer
{

    public function adminSystemConfigChangedSECTIONNAME(Varien_Event_Observer $observer)
    {
        // Your code here
    }

}

Before testing your code, don’t forget to flush caches if they are enabled !

NB : You can retrieve the sent values in the config in your observer :

<?php
// ...

public function adminSystemConfigChangedSECTIONNAME(Varien_Event_Observer $observer)
    {
        $configValue = Mage::getStoreConfig('sectionName/groupName/fieldName');
    }

	// ...
?>
Call an Event after a System Config save
Tagged on:                     

Leave a Reply

Your email address will not be published. Required fields are marked *

We use cookies to ensure that we give you the best experience on our website.
Ok