Magento admin panel custom button in order view page.
Magento admin panel custom button in order view page.

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.

Config.xml:

app/code/[CodePool]/[NameSpace]/[ModuleName]/config.xml
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
[crayon-5e43cceec11d9248326122/]

Observer.php

This is the file which has the observer class and we can declare our method which we have defined in config.xml file.
app/code/[CodePool]/[NameSpace]/[ModuleName]/Observer.php
e.g: app/code/local/JRB/Custombutton/Observer.php
[crayon-5e43cceec11e1694831326/]
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.

Config.xml:
app/code/[CodePool]/[NameSpace]/[ModuleName]/config.xml
e.g: app/code/local/JRB/Custombutton/config.xml

[crayon-5e43cceec11e5937949918/]
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.

View.php:

app/code/[CodePool]/[NameSpace]/[ModuleName]/Block/Adminhtml/Sales/Order/View.php
e.g: app/code/local/JRB/Custombutton/Block/Adminhtml/Sales/Order/View.php
[crayon-5e43cceec11ea721106177/]
The above code has the same concept but only different is, it just overrides Mage_Adminhtml_Block_Sales_Order_View class.

Magento admin panel custom button in order view page
The following two tabs change content below.
Jyotiranjan is one of passionate programmer who has been working in magento since 6 years and in the mean time he has developed enormous amount of modules and customisation of sites. He loves to write blogs and travel for long journeying.

Latest posts by Jyotiranjan Biswal (see all)

Tagged on:                         

Leave a Reply

Your email address will not be published. Required fields are marked *