2
votes

How do I add a new tab to the sales order view in Magento without modifying core code? I've seen a few tutorials on the web, but they want you to add/modify files in /app/design/adminhtml/default/default/template.

Is this a core directory? When you install a plugin, can it install to these directories?

1

1 Answers

6
votes

Modifying default theme is wrong in many ways, so I wouldn't recomment it.

If this new tab is a part of your extension, you can insert your own tab by adding it in your layout update file for adminhtml.

If you still don't have such file, you have to add layout file declaration in your config.xml

<adminhtml>
    <layout>
        <updates>
            <my_extension>
                <file>my_extension.xml</file>
            </my_extension>
        </updates>
    </layout>
</adminhtml>

Then you have to create a file named my_extension.xml (as you declared it in config.xml) in /app/design/adminhtml/default/default/layout/ with the following content:

<?xml version="1.0"?>
<layout version="0.1.0">
    <adminhtml_sales_order_view>
        <reference name="sales_order_tabs">
            <action method="addTab"><name>my_tab</name><block>my_extension/Adminhtml_Sales_Order_View_Tab_Custom</block></action>
        </reference>
    </adminhtml_sales_order_view>
</layout>

But make sure that the block you insert implements Mage_Adminhtml_Block_Widget_Tab_Interface.

UPDATE: I've edited answer to be more beginner-friendly