Now in this article I am going to show you how simply you can set Magento admin panel custom button in order view page.Generally it can be done by overriding sales_order_view block into your custom module but I can only prefer ot do in observer because it won’t affect any ones module or never depend upon anyone’s module .For example if some might be already overrides that code in your site then you can’t do it again.Either you can place your code into their module or extend the block who has override the core sales_order_view block.This problem will occur if you will try to override but if you will do through observer then do independently. So.So lets see how we can implement Magento admin panel custom button in order view page.For that you need to have little concept of event observer in magento. So.So then after you can understand easily all the below explanations with code.Here i am not explaing everything form beginning of module I mean I am not explaining how to create a module because module creation is not our concern.Our concern is how to add custom button.Simply for managing through observer we need to two files one config.xml another is Observer.php where our desire method will place.
This is the simple module declation file where we can declare every functionality or rout of work.So lets add our new work or functionality in this file.So it would be at event section as we are going to set event and to capture that.
In my case I have a module called JRB_Custombutton.Then My config.xml file would be at app/code/local/JRB/Custombutton/config.xml
This is the file which has the observer class and we can declare our method which we have defined in config.xml file.
The above code set the custom button and points to a controller url by onclick evetn on button. Because We don’t only the button If the button do some work then there meaning to set the button.So the url set there points to module controller file where you can do your desire work lie export order etc. or you can do any custom work over there by passing order id or any argument as parameter through the url.
Still if you feel your overriding concept is better then you can follwo below code for Magento admin panel custom button in order view page.Lets see how that ce be.
Same concept as above we need to have two file one is config.xml file another is our overrides file that is View.php.
In above code we have override by rewrite to “sales_order_view” and set method in our module then after we extend core file to our module file.lets see below.
The above code has the same concept but only different is, it just overrides Mage_Adminhtml_Block_Sales_Order_View class.