I want to disable the cancel order button from Magento admin order view page as well as from order grid page.

Though I know using the Roles we can disable this but I want to do this for some specific condition for a role.

So I am trying the code mentioned on the following link https://stackoverflow.com/questions/32788869/how-to-prevent-an-order-from-getting-cancelled-using-event-observer on stackoverflow.com Though the code does not hide the cancel button it try to prevent the order being cancel. But the code is not working for me and order is still canceled.

1) Do we have any approach using event observer to disable the particular button on order view page as well as order grid.

2) Do I need to override the core/Mage/Adminhtml/Block/Sales/Order/View.php file?

Please suggest some solution for same.

order grid

enter image description here

1 Answer 1


For this case,Better idea to use Event/Observer.

In magento,on class Mage_Adminhtml_Block_Widget_Container there have a function removeButton($id).

By using this function and with help event adminhtml_widget_container_html_before,

You can remove cancel button from order view.



public function adminhtmlWidgetContainerHtmlBefore($event)
    $block = $event->getBlock();

    if ($block instanceof Mage_Adminhtml_Block_Sales_Order_View) {


You see more details at https://stackoverflow.com/a/25565340/2940291


remove cancel from order grid

use core_block_abstract_prepare_layout_before

<!-- another events may which remove button from grid -->



public function removeButtoncancel($observer)
    $block = $observer->getEvent()->getBlock();
    if(get_class($block) =='Mage_Adminhtml_Block_Widget_Grid_Massaction'
        && $block->getRequest()->getControllerName() == 'sales_order')

As observer is not works then try with block class rewrite Mage_Adminhtml_Block_Sales_Order_Grid.

Define rewrite in config.xml



Rewrite class

class [ModuleNameSpace]_[ModuleName]_Block_Adminhtml_Sales_Order_Grid extends

    protected function _prepareMassaction()
        return $this;

Get full module:

Goto git hub

  • Thanks, I will try this solution and if it works I will upvote.Do you know how can I remove the cancel action from actions dropdown.I do not want to use Role.
    – Mukesh
    Sep 26, 2015 at 19:02
  • I tried the solution provided by you but it is not working.Control reaches to the methods but button is still there.
    – Mukesh
    Sep 27, 2015 at 6:49
  • answered update and it working
    – Amit Bera
    Sep 27, 2015 at 13:26

Your Answer

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

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