I have a custom module which I am using to do some advanced operation on product. Using my module, I have overwrite the tabs file of adminhtml_catalog_product_edit_tabs in order to appear my custom tab on catalog_prdouct_edit page in admin. Now the tab appears above all default tabs.
(See Combo Products tab)
I need to appear this tab below cross-sells tab(which is a default tab).
local/Mysite/combooffers/etc/config.xml
<config>
<modules>
<Mysite_Combooffers>
<version>0.1.0</version>
</Mysite_Combooffers>
</modules>
<frontend>
<routers>
<Combooffers>
<use>standard</use>
<args>
<module>Mysite_Combooffers</module>
<frontName>combooffers</frontName>
</args>
</Combooffers>
</routers>
<layout>
<updates>
<combooffers>
<file>combooffers.xml</file>
</combooffers>
</updates>
</layout>
</frontend>
<admin>
<routers>
<combooffers>
<use>admin</use>
<args>
<module>Mysite_Combooffers</module>
<frontName>combooffers</frontName>
</args>
</combooffers>
</routers>
</admin>
<global>
<blocks>
<combooffers>
<class>Mysite_Combooffers_Block</class>
</combooffers>
<adminhtml>
<rewrite>
<catalog_product_edit_tabs>Mysite_Combooffers_Block_Adminhtml_Catalog_Product_Edit_Tabs</catalog_product_edit_tabs>
</rewrite>
</adminhtml>
</blocks>
<helpers>
<combooffers>
<class>Mysite_Combooffers_Helper</class>
</combooffers>
</helpers>
</global>
</config>
local/Mysite/Combooffers/Block/Adminhtml/Catalog/Product/Edit/Tabs.php
<?php
class Mysite_Combooffers_Block_Adminhtml_Catalog_Product_Edit_Tabs extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs
{
protected function _prepareLayout()
{
$this->addTab('combooffer', array(
'label' => Mage::helper('catalog')->__('Combo Products'),
'content' => $this->getLayout()->createBlock('combooffers/adminhtml_catalog_product_edit_tab_Combooffer')->toHtml(),
));
return parent::_prepareLayout();
}
}
Mysite/Combooffers/Block/Adminhtml/Catalog/Product/Edit/Tab/Combooffer.php
<?php
class Mysite_Combooffers_Block_Adminhtml_Catalog_Product_Edit_Tab_Combooffer extends Mage_Adminhtml_Block_Widget_Form
{
protected function _prepareForm()
{
$productId = $this->getRequest()->getParam('id');
$storeId = $this->getRequest()->getParam('store');
if(!$storeId) $storeId=0;
$form = new Varien_Data_Form();
$fieldset = $form->addFieldset('combooffer_form', array('legend'=>Mage::helper('combooffers')->__('Combo Products')));
// You can write your code here
$this->setForm($form);
return parent::_prepareForm();
}
public function getTabTitle()
{
return Mage::helper('combooffers')->__('Combo Products');
}
public function canShowTab()
{
return true;
}
public function getTabUrl()
{
return $this->getUrl('*/*/combooffers', array('_current' => true));
}
public function isHidden()
{
return false;
}
}
How can achieve this. Please give a hint for this problem.
Best Answer
When you create your own tab you can use the index 'after' as shown below.
In [tab_id] you insert a real tab_id created by Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs block like 'inventory', 'websites' or 'categories'. When you do this, the responsible block for the output of the tabs makes a reorder automatically in _beforeToHtml() method (see Mage_Adminhtml_Block_Widget_Tabs:: _beforeToHtml()).
Good luck.
Tiago Sampaio