-1

I need to add a new tab on (adminhtml) order->view on Magento CE 1.9.1. I've tried with some guides found on Google but nothing worked. Anybody can help me?

tabris963
  • 110
  • 2
  • 14
  • if you know basic about module creation this [link](http://stackoverflow.com/questions/7084786/how-do-i-add-a-tab-to-the-sale-order-admin-page) may help. – Milan Chandro Aug 26 '15 at 04:11

1 Answers1

4

Here is the example module.

file: app/code/local/Namespace/Newtab/Block/Adminhtml/Order/View/Tab/Contents.php

<?php
class Namespace_Newtab_Block_Adminhtml_Order_View_Tab_Contents
    extends Mage_Adminhtml_Block_Template
    implements Mage_Adminhtml_Block_Widget_Tab_Interface
{    
    public function _construct()
    {
        parent::_construct();
        $this->setTemplate('namespace/newtab/order/view/tab/contents.phtml');

    }

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

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

    public function canShowTab() {
        return true;
    }

    public function isHidden() {
        return false;
    }

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

file: app/code/local/Namespace/Newtab/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Namespace_Newtab>
            <version>1.0.1</version>
        </Namespace_Newtab>
    </modules>
    <global>
        <blocks>
            <namespace_newtab>
                <class>Namespace_Newtab_Block</class>
            </namespace_newtab>
        </blocks>
    </global>       
    <adminhtml>
       <layout>
            <updates>
                <namespace_newtab>
                    <file>namespace_newtab.xml</file>
                </namespace_newtab>
            </updates>
        </layout>
    </adminhtml>
</config>

file: app/design/adminhtml/default/default/layout/namespace_newtab.xml

<?xml version="1.0"?>
<layout>
    <adminhtml_sales_order_view>
        <reference name="sales_order_tabs">
            <action method="addTab">
                <name>namespace_newtab_order_view_tab</name>
                 <block>namespace_newtab/adminhtml_order_view_tab_contents</block>
            </action>
        </reference>
</adminhtml_sales_order_view>
</layout>  

file: app/design/adminhtml/default/default/template/namespace/newtab/order/view/tab/contents.phtml

<?php echo 'Hello World!';?>  

file: app/etc/modules/Namespace_Newtab.xml

<?xml version="1.0"?>
<config>
     <modules>
        <Namespace_Newtab>
            <active>true</active>
            <codePool>local</codePool>
        </Namespace_Newtab>
    </modules>
</config>
Milan Chandro
  • 2,342
  • 1
  • 18
  • 25
  • Hi Milan-Chandro, thanks for your help. I followed all the steps but unluckily it's not working... I've also tried to apply some changes (in @osdave's example you linked there was a shorter path for the template), but still nothing... However after I upload the files and use "flush magento cache" from "cache management" I can see the module (displayed as active) on the list in Configuration->Advanced Do you have any idea about what could be the problem? Am I missing an obvious step not mentioned here? Maybe I shouldn't use "flush magento cache"? – tabris963 Aug 26 '15 at 10:49
  • Update. I tried copying completely your code, and it works. In my previous attempt I've only modified the Namespace with "Tb963"... Could numbers in the namespace be the problem? – tabris963 Aug 26 '15 at 15:26
  • Last update. Trying again, modifying the namespace adding the numbers (as I was doing at the beginning) it still works. I have no idea why it wasn't working, but then it must definitely be an error of mine. Thank you very much for your help Milan-Chandro :) – tabris963 Aug 26 '15 at 15:38
  • Trying this but not working, Can you please check this out: http://stackoverflow.com/questions/38701292/magento-adding-new-tab-to-order-view-page-not-displaying – Venelin Aug 01 '16 at 14:26
  • How can we create a form there and upload a file through that form? can we use grid instead of phtml? @Milan Chandro – Xabby Mar 16 '17 at 11:58