Create Custom Tab in Magento Product Add/Edit Page

If you are trying to add a custom tab to the product add/edit page in Magento admin, then you are at the right place. Today I will tell you a damn simple method to add the custom tab to product add/edit page. We will have to add few lines to the xml layout file of your custom module. Then create a phtml file that contains the html part to be shown in the tab.


Here is the detailed description of the process:
1. Create a directory named ‘custom’ at appdesignadminhtmldefaultdefaulttemplate location.

2. Create file named content.phtml in the above directory so that the full path looks like appdesignadminhtmldefaultdefaulttemplatecustomcontent.phtml

3. In content.phtml you can write any php and html code according to your need.

<?php
//Get the current product
$product = Mage::registry('product');
?>

<div class="entry-edit">
<div class="entry-edit-head">
<h4 class="icon-head head-edit-form fieldset-legend">Custom Tab</h4>
</div>
<div id="group_fields4" class="fieldset fieldset-wide">
<?php
var_dump($product);
?>
</div>
</div>

4. Create the block file in appcodelocal<namespace><module_name>BlockAdminhtmlConfig.php. Add following content to the file:

<?php
class <namespace>_<module_name>_Block_Adminhtml_Config extends Mage_Core_Block_Template implements Mage_Adminhtml_Block_Widget_Tab_Interface
{
public function __construct(){
$this->setTemplate('custom/content.phtml');
parent::__construct();
}

//Label to be shown in the tab
public function getTabLabel(){
return Mage::helper('core')->__('Custom Tab');
}

public function getTabTitle(){
return Mage::helper('core')->__('Custom Tab');
}

public function canShowTab(){
return true;
}

public function isHidden(){
return false;
}
}

5. Open the appdesignadminhtmldefaultdefaultlayout<module_name>.xml. Add following lines to this file:

<!-- To add a tab on new product page -->
<adminhtml_catalog_product_new>
<reference name="product_tabs">
<action method="addTab">
<name>custom_tab</name>
<block template="custom/content.phtml">module_name/adminhtml_config</block>
</action>
</reference>
</adminhtml_catalog_product_new>
<!-- To add a tab on new product page -->


<!-- To add a tab on edit product page -->
<adminhtml_catalog_product_edit>
<reference name="product_tabs">
<action method="addTab">
<name>custom_tab</name>
<block template="custom/content.phtml">module_name/adminhtml_config</block>
</action>
</reference>
</adminhtml_catalog_product_edit>
<!-- To add a tab on edit product page -->

This is all and you are done! Please share if you like it.

Written by Arvind Bhardwaj

Arvind is a certified Magento 2 expert with more than 10 years of industry-wide experience.

Website: http://www.webspeaks.in/

14 thoughts on “Create Custom Tab in Magento Product Add/Edit Page

  1. Hi Arvind!

    Thanks for this great post, but I see one problem. The new tab is also visible in the “new product”-page, where you can define a simple, configured product et cetera. How can I prevent the tab is displayed?

    Regards,

    Danilo

  2. I am using 1.7.0.0 and I have done all that is listed but I cannot get this to show anywhere… I have logged out and logged back into the admin cp.

    I tried the default attribute set as well as my custom ones, neither are showing anythings.. has anything changed since 1.7.0.0 or the new 1.7…. whatever it is now as of today.

    thanks for the assistance and for this, been wanting to get back some functionality I had with Prestashop.. and this is the only thing they had. I am trying to add where I can make links to downloaded PDF files for the products.

  3. I have been trying to get this to work with v1.7.0.0, I have done all that is listed but I cannot get it to show up anywhere.

    I tried logging out and logging back in but with no success. I have looked at products created using the default attribute set as well as my custom ones and tried creating new products in the same fashion.

    Has anything changed in the newer versions to cause this to not function the same way?

    I am trying to add back one of the only things that Prestashop has or had over Magento and that is downloadable files for a given product.. so I thought I would create a custom tab for these products and just make general PDF links.

    thanks for your assistance and for this tutorial!

    1. @Bradley, As far as I know this code works well with v1.7. Only thing I can suggest right now is to recheck your code, specially the XMLs because you know that Magento greatly depends on XMLs

  4. Hi, thanks for your article.
    I tried this in Magento 1.7.0.2, but not works for me…
    Could you explain better the step 5?
    There are some place where I can download this sample and see if works on my site?
    Thanks

  5. Hi,

    Thanks for the article.

    The only problem I see is that as a result we get a tab page but not a form widget which would be much more useful.

  6. hi friend’s

    that’s not don because when click add new product that time magento ask
    Create Product Settings in Settings TAB it’s code display over Custom tab after Settings tab so fair it bug any one solve this (hu..) 🙂

  7. HI..

    Nice article and it simplest way for create product admin grid in magento.Here I had facing this problem. I follow your instruction to create admin product grid .But it doesnot working for me…How to solve it.any one can help me…..

  8. One step this article leaves out is the necessity to define your blocks in your modules config.xml.

    Example (code is inside config.xml):

    NAMESPACE_MODULENAME_Block

  9. "Create custom tab in product page admin" this page on top result in google.
    I add <layout> to appdesignadminhtmldefaultdefaultlayout<module_name>.xml
    But this not help me
    Magento 1.9.3.1

Comments are closed.