Magento Coding Solutions

how To add Custom Tab in admin Cetalog Product programmatically


We  want to add New Tab "Manage Weight" to manage My custom Code
1)Create a module "example NameSpace: Jewelry and Module Name: Basicprice "
2) Do Change in Module
                i)  in config.xml
                                <global>
                                                <blocks>
                                                                 <basicprice>
                                                                                <class>Jewelry_Basicprice_Block</class>
                                                                  </basicprice>                                                  
                                                </blocks>
                                </global>
replace  this code to overwrite product TAB
Code is:
<global>
<blocks> <basicprice><class>Jewelry_Basicprice_Block</class>  </basicprice>  
<adminhtml> <rewrite>                                                                                                   <catalog_product_edit_tabs>Jewelry_Basicprice_Block_Adminhtml_Tabs</catalog_product_edit_tabs></rewrite></adminhtml></blocks>
</global>
ii) Make a file "Tabs.php" in location app/code/local/Company/ModuleName/Block/Adminhtml/tabs.php
and past this code
<?php
class Jewelry_Basicprice_Block_Adminhtml_Tabs extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs
{    public $parent;
    protected function _prepareLayout()    {
        //get all existing tabs
        $this->parent = parent::_prepareLayout();
        //add new tab
        $this->addTab('tabid', array(
            'label'     => Mage::helper('catalog')->__(' Manage Weight'),
            'content'   => $this->getLayout()->createBlock('basicprice/adminhtml_tabs_tabid')->toHtml(),

        ));
        return $this->parent;
    }
}?>

/public_html/app/code/local/Company/ModuleName/Block/Adminhtml/tabs.php
iii)Make a folder "Tabs" in location  app/code/local/Company/ModuleName/Block/Adminhtml/tabs/
iv) Create a "Tabid.php" file in location app/code/local/Company/ModuleName/Block/Adminhtml/tabs/ Tabid.php
and past this code
<?php
class Jewelry_Basicprice_Block_Adminhtml_Tabs_Tabid extends Mage_Adminhtml_Block_Widget
{    public function __construct()
    {        parent::__construct();
        $this->setTemplate('weight.phtml');
    }
}
?>

v) create a file weight.phtml in location  "app/design/adminhtml/default/default/template/ weight.phtml "
to manage Your custom code
Example:



No comments:

Post a Comment