0

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?

Manashvi Birla
8,8739 gold badges29 silver badges53 bronze badges
asked Mar 24, 2015 at 22:39
3
  • Is your observer (method adminhtmlWidgetContainerHtmlBefore) being invoked? Commented Mar 25, 2015 at 1:00
  • Your module files seems ok for me except for the observer definition. You need to use class instead of Class in your Observer.php. Also clear the cache and then try again. Commented Mar 25, 2015 at 1:09
  • I don't think the function adminhtmlWidgetContainerHtmlBefore is being called. I added a var_dump / die line to it and nothing happens at all on the front end. Also changed "class" to lowercase and the problem persists. Commented Mar 25, 2015 at 22:31

1 Answer 1

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.

answered Mar 25, 2015 at 23:49
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.