0

I want to create a custom button in magento 1 backend in **order tab.** locatation wanted for the button I want this button to be General(for all orders), but i can't find anything related to my issue. All i find it's this article article, but it not help me to much because they create a button for product catalog tab.

Dose anyone know what steps i need to follow to do this? Any advice will be greatly appreciated

  • use adminhtml/sales_order instead of adminhtml/catalog_product – Gopal Patel Apr 11 '17 at 7:03
0

Try Below Code :

You need to first overwrite observer : adminhtml_widget_container_html_before

<adminhtml_widget_container_html_before>
    <observers>
         <add_button_test>
             <class>your_module_name/observer</class>
             <method>addNewButton</method>
         </add_button_test>
    </observers>
</adminhtml_widget_container_html_before>

After This open Observer file from model which is you overwrite :

public function addNewButton($observer)
{
    $container = $observer->getBlock();
    if(null !== $container && $container->getType() == 'adminhtml/sales_order') {
        $data = array(
            'label'     => 'My button',
            'class'     => 'some-class',
            'onclick'   => 'setLocation(\' '  . Mage::getUrl('*/*', array('param' => 'value')) . '\')',
        );
        $container->addButton('my_button_identifier', $data);
    }

    return $this;
}

Clear Cache and Refresh order Grid.

Happy Coding. :)

  • if i add this code, i can send my button to a controller? – Alin Lupoiu Apr 11 '17 at 7:37
  • yes you can just set your controller action in setLocation – Ajay Patel Apr 11 '17 at 16:33

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.