3

I am using this event to add a new button:

controller_action_layout_render_before_adminhtml_sales_billing_agreement_view

This is my function:

    var_dump(Mage::getSingleton('core/layout')->getUpdate()->getHandles());
    if (!$block = Mage::app()->getLayout()->getBlock('adminhtml_sales_billing_agreement_view')) {
        return $this;
    }
    $block->addButton('test',[
        'label' => Mage::helper('mynamespace_mymodule')->__('Test'),
        'class' => 'test'
    ]);

    return $this;

The result of my var_dump is array(4) { [0]=> string(7) "default" [1]=> string(11) "STORE_admin" [2]=> string(31) "THEME_adminhtml_default_default" [3]=> string(38) "adminhtml_sales_billing_agreement_view" }. But I cannot get my block, it doesn't get to the point to add my new button. It always returns $this. Maybe my block name is incorrect. Any idea ?

Thank you

1

Please try this:

  • change event to adminhtml_block_html_before
  • observer code

    if ($block->getType() == 'sales/adminhtml_billing_agreement_view') {
        $block->addButton('test', array(
            'label' => 'Test',
            'class' => 'test'
        ));
    }
    
  • 2
    This event adminhtml_widget_container_html_before works as well :) – Attila Naghi Mar 6 '18 at 9:01
1

Using this event: adminhtml_widget_container_html_before

and in the function called :

public function adminhtmlWidgetContainerHtmlBefore(Varien_Event_Observer $observer)
{
   $block = $observer->getBlock();

   if ($block instanceof your_class_here)    {
       $block->addButton('truncate_quote', array(
                'label'     =>  Mage::helper('mynamespace_mymodule')->__('Your Label Name'),
                'class'     => 'go'
            ));
       //or remove a button
       $block->removeButton('your button');
   }

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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