I want to add a custom tab to the order page in the admin of magento. Is there a way to do this with a simple override?
Assuming you know how to do a module, here are the steps you need to perform:
layout update: in your admin's xml layout file you want to "listening" to the admin's order view rendering handle and add your tab:
<layout>
<adminhtml_sales_order_view>
<reference name="sales_order_tabs">
<action method="addTab"><name>the_name_of_your_tab</name><block>the_block_alias_of_your_module/path_to_your_tab_file</block></action>
</reference>
</adminhtml_sales_order_view>
</layout>
the tab file: I generally try to respect Magento's folder structure, so this file would be in app/code/local-or-community/YourNamespace/YourModule/Block/Adminhtml/Order/View/Tab/File.php and will have at least:
<?php
class YourNamespace_YourModule_Block_Adminhtml_Order_View_Tab_File
extends Mage_Adminhtml_Block_Template
implements Mage_Adminhtml_Block_Widget_Tab_Interface
{
protected $_chat = null;
protected function _construct()
{
parent::_construct();
$this->setTemplate('yourmodule/order/view/tab/file.phtml');
}
public function getTabLabel() {
return $this->__('Tab label');
}
public function getTabTitle() {
return $this->__('Tab title');
}
public function canShowTab() {
return true;
}
public function isHidden() {
return false;
}
public function getOrder(){
return Mage::registry('current_order');
}
The .phtml file, which has to respect the path you specified in the block's __construct(), and should hace something like:
<div class="entry-edit">
<div class="entry-edit-head">
<h4><?php echo $this->__('a title'); ?></h4>
</div>
<div class="fieldset fieldset-wide">
the content you want to show
</div>
</div>
Hope That Helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With