I am trying to add a simple generic button to the Sales Order View page using the adminhtml_widget_container_html_before event but no matter what I try the button will not appear.
Here is my code:
/app/etc/modules/ZeroBars_Approvebutton.xml
<?xml version="1.0"?>
<config>
<modules>
<ZeroBars_Approvebutton>
<active>true</active>
<codePool>local</codePool>
</ZeroBars_Approvebutton>
</modules>
</config>
/app/code/local/ZeroBars/Approvebutton/etc/config.xml
<config>
<modules>
<ZeroBars_Approvebutton>
<version>0.0.1</version>
</ZeroBars_Approvebutton>
</modules>
<global>
<models>
<zerobars_approvebutton>
<class>ZeroBars_Approvebutton_Model</class>
</zerobars_approvebutton>
</models>
<helpers>
<zerobars_approvebutton>
<class>ZeroBars_Approvebutton_Helper</class>
</zerobars_approvebutton>
</helpers>
<adminhtml>
<events>
<adminhtml_widget_container_html_before>
<observers>
<zerobars_approvebutton>
<class>zerobars_approvebutton/observer</class>
<method>adminhtmlWidgetContainerHtmlBefore</method>
</zeroBars_approvebutton>
</observers>
</adminhtml_widget_container_html_before>
</events>
</adminhtml>
</config>
/app/code/local/ZeroBars/Approvebutton/Model/Observer.php
<?php
Class ZeroBars_Approvebutton_Model_Observer
{
public function adminhtmlWidgetContainerHtmlBefore($event) {
$block = $event->getBlock();
if ($block instanceof Mage_Adminhtml_Block_Sales_Order_View) {
$block->addButton('do_something_crazy', array(
'label' => Mage::helper('module')->__('Button'),
'onclick' => "setLocation('{some location}')",
'class' => 'go'
));
}
}
}
The method for adding a button on the page seems pretty straightforward so I am not sure why it is not working. Is there a possibility that another extension is overriding it?
1 Answer 1
In your config.xml you have a <global> node however that is never closed out add </global> before <adminhtml> and it should work everything else looks OK to me.
Explore related questions
See similar questions with these tags.
adminhtmlWidgetContainerHtmlBefore) being invoked?classinstead ofClassin yourObserver.php. Also clear the cache and then try again.