I am trying to add a button in the Customers->Account Information
tab. I want the button to do an action when it is clicked. I would like to do this in a custom module. I'm not too fond of the idea of rewriting core files or any classes. From what I have googled people say you can do this using an Observer
, an example is here , if that is true then I would like to do it this way.
I know how to make a basic module, what I need help on is how do you put a button in a specific tab without rewriting the files/classes?
Update 11/3/2013 11am:
Here is the screenshot
I would like to add the button on this tab.
Update 2:48pm 11/3/2014
Here is my code so far, maybe I am making a mistake somewhere.
My file structure
-app
-local
-Rdtmodules
-ChangeGroupNotification
-etc
-config.xml
-Model
-Observer.php
-etc
-modules
-Rdtmodules_ChangeGroupNotification.xml
config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Rdtmodules_ChangeGroupNotification>
<version>1.0.0</version>
</Rdtmodules_ChangeGroupNotification>
</modules>
<global>
<models>
<rdtmodules_changegroupnotification>
<class>Rdtmodules_ChangeGroupNotification_Model</class>
</rdtmodules_changegroupnotification>
</models>
<events>
<adminhtml_block_html_before>
<observers>
<rdtmodules_changegroupnotification>
<class>rdtmodules_changegroupnotification/observer</class>
<method>sendCustomerGroupChangeNotification</method>
<type>singleton</type>
</rdtmodules_changegroupnotification>
</observers>
</adminhtml_block_html_before>
</events>
</global>
</config>
Observer.php
<?php
class Rdtmodules_ChangeGroupNotification_Model_Observer {
public function sendCustomerGroupChangeNotification(Varien_Event_Observer $observer) {
$block = $observer->getEvent()->getData('block');
if($block->getId() == 'customer_edit' && $block->getRequest()->getControllerName() == 'customer_edit') {
$block->addButton('test_print', array(
'label' => 'Test',
'onclick' =>'setLocation(\'' . $block->getUrl('html/sales_order/print') . '\')',
'class' => 'go'
));
}
}
}