Magento add tab in admin sales order view

Add your custom tab in sales order view.




app/design/adminhtml/default/default/layout/YOUR_FILE_NAME.xml
if not any xml file than add it first to your module config.xml


<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Namespace_Modulename>
            <version>0.1.0</version>
        </Namespace_Modulename>
    </modules>

 <adminhtml>
        <layout>
            <updates>
                <modulename>
                    <file>YOUR_FILE_NAME.xml</file>
                </modulename>
            </updates>
        </layout>        
    </adminhtml>

</config>

Add below code on this file app/design/adminhtml/default/default/layout/YOUR_FILE_NAME.xml


<?xml version="1.0"?>
<layout version="0.1.0">  
   <adminhtml_sales_order_view>
        <reference name="sales_order_tabs">
            <action method="addTab">
                <name>order_view_tab_customorderstatus</name>
                 <block>modulename/adminhtml_order_view_tab_customorderstatus</block>
            </action>
        </reference>
</adminhtml_sales_order_view>  
 
</layout>

Step2:- Add a file Customorderstatus.php on your module app/code/local/Namespace/Modulename/Block/Adminhtml/Order/View/Tab/Customorderstatus.php


<?php
class Namespace_Modulename_Block_Adminhtml_Order_View_Tab_Customorderstatus
    extends Mage_Adminhtml_Block_Template
    implements Mage_Adminhtml_Block_Widget_Tab_Interface
{
    protected $_chat = null;

    protected function _construct()
    {
        parent::_construct();
        $this->setTemplate('modulename/customorderstatus.phtml');
    }

    public function getTabLabel() {
        return $this->__('Add New Tab ');
    }

    public function getTabTitle() {
        return $this->__('Add New Tab Title');
    }

    public function canShowTab() {
        return true;
    }

    public function isHidden() {
        return false;
    }

    public function getOrder(){
        return Mage::registry('current_order');
    }
} 
?>

Step3:- add a file customorderstatus.phtml on your module app/design/adminhtml/default/default/template/modulename/customorderstatus.phtml

Leave a Reply