Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Override admin product toolbar
 
nuranto
Member
 
Total Posts:  35
Joined:  2008-09-30
 

Hi there!

I’m trying to add a tab in the admin add-product toolbar. But i’m in trouble, there a lack of documentation, and I really don’t know where to search, what to do!

Here is my try :

Adding my module (app/etc/)

<?xml version="1.0"?>
<config>
    <
modules>
        <
MyCompany_Adminhtml>
            <
active>true</active>
            <
codePool>local</codePool>
        </
MyCompany_Adminhtml>
    </
modules>
</
config>

Module config file (app/code/local/MyCompany/Adminhtml/etc/)

<?xml version="1.0"?>
<config>
    <global>
        <
blocks>
            <
adminhtml>
                <
rewrite>
                    <
catalog>MyCompany_Adminhtml_Block_Catalog_Product_Edit_Tabs</catalog>
                </
rewrite>
            </
adminhtml>
        </
blocks>
    </global>
</
config>

Override file (app/code/local/MyCompany/Adminhtml/Block/Catalog/Product/Edit/Tabs.php)

<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category   Mage
 * @package    Mage_Adminhtml
 * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */

/**
 * admin product edit tabs
 *
 * @category   MyCompany
 * @package    MyCompany_Adminhtml
 * @author      me
 */
         
die("Hey");
class 
MyCompany_Adminhtml_Block_Catalog_Product_Edit_Tabs extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs
{


    
protected function _prepareLayout()
    
{

        $this
->addTab('newtabname', array(
          
'label'     => Mage::helper('catalog')->__('New Tab Name'),
          
'url'       => $this->getUrl('*/*/newtabname', array('_current' => true)),
          
'class'     => 'ajax',
        ));
        return 
parent::_prepareLayout();
    
}
}

The die isn’t called, so it’s probably a config problem..?

Any ideas ?

Thanks a lot

 
Magento Community Magento Community
Magento Community
Magento Community
 
nuranto
Member
 
Total Posts:  35
Joined:  2008-09-30
 

Ok I got it :

<?xml version="1.0"?>
<config>
    <
modules>
        <
Mycompany_Adminhtml>
            <
version>0.1.0</version>
        </
MyCompany_Adminhtml>
    </
modules>
    <global>
        <
blocks>
            <
adminhtml>
                <
rewrite>
                    <
catalog_product_edit_tabs>MyCompany_Adminhtml_Block_Catalog_Product_Edit_Tabs</catalog_product_edit_tabs>
                </
rewrite>
            </
adminhtml>
        </
blocks>
    </global>
</
config>

But i have another problem. Now i try to override adminhtml/controllers/ProductController.

I tried :

<?xml version="1.0"?>
<config>
    <global>
        <
controllers>
            <
adminhtml>
                <
rewrite>
                    <
catalog_product>MyCompany_Adminhtml_Catalog_ProductController</catalog_product>
                </
rewrite>
            </
adminhtml>
        </
controllers>
    </global>
</
config>
and
<?xml version="1.0"?>
<config>
    <global>
        <
rewrite>
            <
MyCompany_adminhtml_catalog_product>
                <
from><![CDATA[#^/adminhtml/catalog/product/#]]></from>
                       
<to>/adminhtml/catalog/product/</to>
            </
MyCompany_adminhtml_catalog_product>
        </
rewrite>
    </global>
    <
admin>
        <
routers>
            <
MyCompany_adminhtml>
                <use>
standard</use>
                <
args>
                    <
module>MyCompany_Adminhtml</module>
                    <
frontName>adminhtml</frontName>
                </
args>
            </
MyCompany_adminhtml>
        </
routers>
    </
admin>


</
config>

I’m really not at ease with the syntax…

Any ideas ?

 
Magento Community Magento Community
Magento Community
Magento Community
 
nuranto
Member
 
Total Posts:  35
Joined:  2008-09-30
 

Here is the solution… :

<global>
        <
blocks>
            <
adminhtml>
                <
rewrite>
                    <
catalog_product_edit_tabs>MyCompany_Adminhtml_Block_Catalog_Product_Edit_Tabs</catalog_product_edit_tabs>
                </
rewrite>
            </
adminhtml>
                            
        </
blocks>
        

        
    </global>
    
    
    <
admin>
        <
routers>
            <
adminhtml>
                <use>
admin</use>
                <
args>
                    <
module>MyCompany_Adminhtml</module>
                    <
frontName>adminhtml</frontName>
                </
args>
            </
adminhtml>
        </
routers>
    </
admin>

Now I have to use MyNewTab class, in Adminhtml/Block/Catalog/Product/Edit/Tab… I tried to add

<class>MyCompany_Adminhtml_Block_Catalog_Product_Edit_Tab_MyNewTab</class>
in global>blocks>adminhtml of my config.xml, but doesn’t work…
I’ll search for this new pb, but if u have a solution (or a real documentation on config files..)… smile
 
Magento Community Magento Community
Magento Community
Magento Community
 
nuranto
Member
 
Total Posts:  35
Joined:  2008-09-30
 

Wrote too fast, here it is :

<blocks>
            <
adminhtml>
                <
rewrite>
                    <
catalog_product_edit_tabs>MyCompany_Adminhtml_Block_Catalog_Product_Edit_Tabs</catalog_product_edit_tabs>
                    <
catalog_product_edit_tab_mynewtab>MyCompany_Adminhtml_Block_Catalog_Product_Edit_Tab_MyNewTab</catalog_product_edit_tab_mynewtab>
                </
rewrite>
                
            </
adminhtml>
                            
        </
blocks>
 
Magento Community Magento Community
Magento Community
Magento Community
 
coooool
Jr. Member
 
Total Posts:  13
Joined:  2008-12-08
 

I am sure this part is correct.

<blocks>
<adminhtml>
<rewrite>
<catalog_product_edit_tabs>MyCompany_Adminhtml_Block_Catalog_Product_Edit_Tabs</catalog_product_edit_tabs>
<catalog_product_edit_tab_mynewtab>MyCompany_Adminhtml_Block_Catalog_Product_Edit_Tab_MyNewTab</catalog_product_edit_tab_mynewtab>
</rewrite>

</adminhtml>

</blocks>

But how about the controller part? I am now working on the same product controller in the admin panel.

Can you provide your finding on that please?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Perrine L
Jr. Member
 
Total Posts:  22
Joined:  2009-05-11
France
 

Hello,

I’m trying to do it too, I have added a new tab on the edit product page, ok, but after… I don’t know how to display a form in the central column… I looked at the side of “app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit” ... but that’s very specific, and I have no idea about how to do…

I need your help.

Thank you.

EDIT : ok I did it. See the thread : http://www.magentocommerce.com/boards/viewthread/43672/

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top