In Magento you can override a block (or helper, or model, etc.) from one module in another one (most common from Magento Adminhtml module). Now I have the problem that I wan
The best way to overcome this problem using, layout after or before observer.
app/code/local/My/Module/etc/config.xml
mymodule/adminhtml_observer
onBlockHtmlBefore
or can use event: core_block_abstract_prepare_layout_after.
And in Observer:
class My_Module_Model_Adminhtml_Observer
{
public function onBlockHtmlBefore(Varien_Event_Observer $observer) {
$block = $observer->getBlock();
if (!isset($block)) return;
switch ($block->getType()) {
case 'adminhtml/catalog_product_grid': //or here you can put any other block
/*For example i am using Mage_Adminhtml_Block_Catalog_Product_Grid, and want to add a column*/
$block->addColumn('COLUMN_ID', array(
'header' => Mage::helper('mymodule')->__('COLUMN HEADER'),
'index' => 'COLUMN_ID',
));
break;
case 'adminhtml/catalog_product_edit_tabs':
/*Or i want to add new tab to admin product edit*/
/* @var $block Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs */
$block->addTab('tab_name', array(
'label' => Mage::helper('catalog')->__('Tab Tilte'),
'content' => $block->getLayout()->createBlock('modulename/adminhtml_product_edit_tabname')->toHtml(),
'after' => 'inventory',
));
break;
}
}
}
While adding tab then you can take reference of product edit tabs to add your form fields into that using you module.
Hope this will be helpful to some one :)