1

I need to config a observer to detect when a option created in system.xml change its value.

The field is made by the code above:

<config>
    <sections>
         <dev>
            <groups>
                <pico_group>
                    <label>SGPico Configurações</label>
                    <frontend_type>text</frontend_type>
                    <sort_order>250</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <fields>
                        <ativo translate="label">
                            <label>Pico está Ativo?</label>
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>1</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </ativo>
                    </fields>
                </pico_group>
            </groups>
        </dev>
    </sections>
</config>

I search and tried to config the observer like that:

<admin_system_config_changed_section_dev_pico_group>
    <observers>
        <auto_invoice_order>
            <type>singleton</type>
            <class>IsabelaFlores_SGPico_Model_Observer</class>
            <method>teste</method>
        </auto_invoice_order>
    </observers>
</admin_system_config_changed_section_dev_pico_group>

But it didn't work

0

The right name of the event is

admin_system_config_changed_section_yoursectionname

group name pico_group is not necessary in your event observer configuration.

<admin_system_config_changed_section_dev> 
    <observers> 
        <auto_invoice_order> 
            <type>singleton</type> 
            <class>IsabelaFlores_SGPico_Model_Observer</class> 
            <method>teste</method> 
        </auto_invoice_order> 
    </observers> 
</admin_system_config_changed_section_dev> 
  • Thank you very much, I change the name and it is working now – Nathália Pissuti Feb 11 at 18:11
  • @NatháliaPissuti não tem problema, am glad it helps. As an additional information, this event has been fired from the file app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php inside the method saveAction // website and store codes can be used in event implementation, so set them as well Mage::dispatchEvent("admin_system_config_changed_section_{$section}", array('website' => $website, 'store' => $store) ); – Haijerome Feb 12 at 5:22
  • Aslo check these answers for other alternate events that you can observe magento.stackexchange.com/a/125336/695 magento.stackexchange.com/a/40854/695 – Haijerome Feb 12 at 5:37

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.