I am trying to add a button with a backend handler. Here's the code
Admin config: system.xml
<sync_now_button translate="label">
<label>Sync Now</label>
<frontend_type>button</frontend_type>
<backend_model><namespace>_<module>/backend_syncnow</backend_model>
<sort_order>40</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</sync_now_button>
Backend model: <namespace>/<module>/Model/Syncnow.php
<?php$
class <namespace>_<module>_Backend_Syncnow extends Mage_Core_Model_Config_Data
{
public function _afterSave()
{
Zend_Debug::dump('sync now');
exit;
}
}
When I load the section associated with my configuration, I get following error -
Invalid config field backend model: <namespace>_<module>/backend_syncnow
Trace:
#0 /home/measure9/public_html/demo.smartsearch.com/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php(328): Mage::throwException('Invalid config ...')
#1 /home/measure9/public_html/demo.smartsearch.com/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php(229): Mage_Adminhtml_Block_System_Config_Form->initFields(Object(Varien_Data_Form_Element_Fieldset), Object(Mage_Core_Model_Config_Element), Object(Mage_Core_Model_Config_Element))
#2 /home/measure9/public_html/demo.smartsearch.com/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php(164): Mage_Adminhtml_Block_System_Config_Form->_initGroup(Object(Varien_Data_Form), Object(Mage_Core_Model_Config_Element), Object(Mage_Core_Model_Config_Element))
#3 /home/measure9/public_html/demo.smartsearch.com/app/code/core/Mage/Adminhtml/Block/System/Config/Edit.php(92): Mage_Adminhtml_Block_System_Config_Form->initForm()
#4 /home/measure9/public_html/demo.smartsearch.com/app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php(107): Mage_Adminhtml_Block_System_Config_Edit->initForm()
#5 /home/measure9/public_html/demo.smartsearch.com/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Adminhtml_System_ConfigController->editAction()
#6 /home/measure9/public_html/demo.smartsearch.com/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('edit')
#7 /home/measure9/public_html/demo.smartsearch.com/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#8 /home/measure9/public_html/demo.smartsearch.com/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#9 /home/measure9/public_html/demo.smartsearch.com/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#10 /home/measure9/public_html/demo.smartsearch.com/index.php(87): Mage::run('', 'store')
#11 {main}
Any pointers what could be wrong with my configuration?
Update #1:
I have managed to solve my issue partially. I changed the class name from <namespace>_<module>_Backend_Syncnow
to <namespace>_<module>_Model_Syncnow
and I can see the button on the UI. However, the button does not show text and clicking on the button does not invoke my model.
P.S. <namespace>
and <module>
are just placeholders.
<namespace>
and<module>
?Observer
forcatalog_product_after_save
event, so saving and retrieving them works fine too. Updated the question with a node. Thanks.config.xml
(which is what should be referenced when declaring yourbackend_model
).<namespace>
in<backend_model>
tag, then the site complains that it was unable to load the module.