Mahmood Rehman
Mahmood Rehman

Reputation: 4331

How to rewrite or add custom tab to the sales order view?

I want to add custom tab to sales order view page. I have tried the following code but nothing has happened.

My module.xml code is below:

 <adminhtml_sales_order_view>
        <reference name="sales_order_tabs">
            <action method="addTab"><name>my_tab</name><block>mymodule/Adminhtml_Sales_Order_View_Tabs</block></action>
        </reference>
</adminhtml_sales_order_view>

And my block class is:

class Mymodule_Block_Adminhtml_Sales_Order_View_Tabs  extends Mage_Adminhtml_Block_Sales_Order_Abstract
    implements Mage_Adminhtml_Block_Widget_Tab_Interface
{

    protected function _construct()
    {
     Mage::Log("Fraud created");
    }

    /**
     * Retrieve order model instance
     *
     * @return Mage_Sales_Model_Order
     */
    public function getOrder()
    {
        return Mage::registry('current_order');
    }

    /**
     * Retrieve source model instance
     *
     * @return Mage_Sales_Model_Order
     */
    public function getSource()
    {
        return $this->getOrder();
    }


    public function getTabLabel()
    {
        return Mage::helper('sales')->__('Fraud Detection');
    }

    public function getTabTitle()
    {
        return Mage::helper('sales')->__('Fraud Detection');
    }

    public function canShowTab()
    {
        return true;
    }

    public function isHidden()
    {
        return false;
    }
}

Any error in the above code?

Upvotes: 2

Views: 2862

Answers (1)

Qazi Mustafa
Qazi Mustafa

Reputation: 21

It can be done by extending/overriding Mage_Adminhtml_Block_Sales_Order_View_Tabs:

$this->addTab('testing', array(
            'label'     => Mage::helper('catalogrule')->__('my_tab'),
            'title'     => Mage::helper('catalogrule')->__('my_tab'),
            'content'   => $this->getLayout()->createBlock('your/block_name')->toHtml(),
        )); 

Upvotes: 1

Related Questions