You have to create custom plugin or add below files in another plugin. There will be 3 – 4 files changes are required to make it work. First you have to create a block file which you need to show in view tab. Current example will show you to create collection grid. You can also show any custom file html.
Lets create a block file in custom plugin in location app/code/local/Techgroup/Return/Block/Adminhtml/Sales/Order/View/Tab/Intake.php
<?php class Techgroup_Return_Block_Adminhtml_Sales_Order_View_Tab_Intake extends Mage_Adminhtml_Block_Widget_Grid implements Mage_Adminhtml_Block_Widget_Tab_Interface { public function __construct() { parent::__construct(); $this->setId('rental_intake'); $this->setUseAjax(true); } protected function _prepareCollection() { $collection = Mage::getModel('return/return')->getCollection(); $collection->join(array( "order" => "sales/order" ), "order.entity_id = main_table.order_id"); $collection->addFieldToFilter("order_id", $this->getOrder()->getId()); $this->setCollection($collection); return parent::_prepareCollection(); } protected function _prepareColumns() { $this->addColumn('return_id', array( 'header' => Mage::helper('sales')->__('ID'), 'index' => 'return_id', 'width' => '120px' )); $this->addColumn('order_id', array( 'header' => Mage::helper('sales')->__('Order ID'), 'index' => 'order_id', 'width' => '120px' )); $this->addColumn('notes', array( 'header' => Mage::helper('sales')->__('Notes'), 'index' => 'notes' )); $this->addColumn('machine_hours', array( 'header' => Mage::helper('sales')->__('Hours'), 'index' => 'machine_hours' )); $this->addColumn('username', array( 'header' => Mage::helper('sales')->__('Username'), 'index' => 'username' )); $this->addColumn('created_at', array( 'header' => Mage::helper('sales')->__('Created At'), 'index' => 'created_at' )); return parent::_prepareColumns(); } /** * Retrieve grid row url * * @return string */ public function getRowUrl($row) { return $this->getUrl('admin_return/adminhtml_return/edit', array( 'id' => $row->getReturnId() )); } /** * Retrieve tab label * * @return string */ public function getTabLabel() { return Mage::helper('sales')->__('Intake'); } /** * Retrieve tab title * * @return string */ public function getTabTitle() { return Mage::helper('sales')->__('Intake'); } /** * Check whether can show tab * * @return bool */ public function canShowTab() { return true; } /** * Check whether tab is hidden * * @return bool */ public function isHidden() { return false; } /** * Retrieve order model instance * * @return Mage_Sales_Model_Order */ public function getOrder() { return Mage::registry('current_order'); } }
Now add layout config in app/code/local/Techgroup/Return/etc/config.xml
<?xml version="1.0"?> <config> <modules> <Techgroup_Return> <version>0.1.0</version> </Techgroup_Return> </modules> <global> <helpers> <return> <class>Techgroup_Return_Helper</class> </return> </helpers> <blocks> <return> <class>Techgroup_Return_Block</class> </return> </blocks> </global> <admin> <routers> <return> <use>admin</use> <args> <module>Techgroup_Return</module> <frontName>admin_return</frontName> </args> </return> </routers> </admin> <adminhtml> <layout> <updates> <return> <file>techgroup_return.xml</file> </return> </updates> </layout> </adminhtml> </config>
Now create layout update xml file at app\design\adminhtml\default\default\layout\techgroup_return.xml
<?xml version="1.0"?> <layout version="0.1.0"> <adminhtml_sales_order_view> <reference name="sales_order_tabs"> <action method="addTab"><name>intake</name><block>return/Adminhtml_Sales_Order_View_Tab_Intake</block></action> </reference> </adminhtml_sales_order_view> </layout>