Add A Tab To The Admin Product Screen

Updated . Posted . Visible to the public.

Declare an admin layout XML file for your module in your config.xml:

<config>
    <adminhtml>
        <layout>
            <updates>
                <your_module>
                    <file>your-module.xml</file>
                </your_module>
            </updates>
        </layout>
    </adminhtml>
</config>

Create the layout XML in /app/design/adminhtml/default/default/layout/your-module.xml:

<?xml version="1.0"?>
<layout>
    <adminhtml_catalog_product_edit>
        <reference name="product_tabs">
            <action method="addTab">
                <name>your_module_some_tab</name>
                <block>your_module/adminhtml_catalog_product_tab</block>
            </action>
        </reference>
    </adminhtml_catalog_product_edit>
</layout>

Create the tab block in {your_module}/Block/Adminhtml/Catalog/Product/Tab.php:

class Your_Module_Block_Adminhtml_Catalog_Product_Tab 
    extends Mage_Adminhtml_Block_Template
    implements Mage_Adminhtml_Block_Widget_Tab_Interface
{
    /**
     * Set the template for the block
     */
    public function _construct()
    {
        parent::_construct();
        
        $this->setTemplate('catalog/product/tab/some-tab.phtml');
    }

    /**
     * Retrieve the label used for the tab relating to this block
     *
     * @return string
     */
    public function getTabLabel()
    {
        return $this->__('Some Tab');
    }

    /**
     * Retrieve the title used by this tab
     *
     * @return string
     */
    public function getTabTitle()
    {
        return $this->__('Some Tab');
    }

    /**
     * Determines whether to display the tab
     * Add logic here to decide whether you want the tab to display
     *
     * @return bool
     */
    public function canShowTab()
    {
        return true;
    }

    /**
     * Stops the tab being hidden
     *
     * @return bool
     */
    public function isHidden()
    {
        return false;
    }
}

Note - you need to create a data helper to support translation, if your module does not have one already.

Make the tabs template in /app/design/adminhtml/default/default/template/catalog/product/tab/some-tab.phtml:

<div class="entry-edit">
    <div class="entry-edit-head">
        <h4>Some Heading</h4>
    </div>
    <div class="fieldset fieldset-wide">
        <div class="hor-scroll">
            <!-- your content here -->
        </div>
    </div>
</div>

Mike Whitby
Last edit
Posted by Mike Whitby to Magento (2012-08-29 10:17)