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

overriding adminhtml? 
 
Neo The Coder
Jr. Member
 
Avatar
Total Posts:  25
Joined:  2009-04-13
 

Hello

is there any possible way to override adminhtml block i mean if someone want to edit existing admin block then where should he write the new code? Say the store switcher code what if i want to make it a table with hyperlinks instead of drop down !!!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
R.
Jr. Member
 
Total Posts:  17
Joined:  2009-09-07
 

adminhtml works like any other module, so to rewrite an adminhtml block, you can write your config.xml like this :

<?xml version="1.0"?>
<config>
    <
modules>
        <
NsName_ModuleName>
            <
version>0.1.0</version>
        </
NsName_ModuleName>
    </
modules>
   <global>
           <
blocks>
            <
adminhtml>
                <
rewrite>
                    <
catalog_product>NsName_ModuleName_Block_Adminhtml_Dashboard_Orders_Grid</catalog_product>
                </
rewrite>
            </
adminhtml>
        </
blocks>
   </global>
</
config>
 
Magento Community Magento Community
Magento Community
Magento Community
 
Neo The Coder
Jr. Member
 
Avatar
Total Posts:  25
Joined:  2009-04-13
 

i have tried the same but it did not work for me the file i was trying to override was

\app\code\core\Mage\Adminhtml\Block\Permissions\User\Edit\Tab\Main.php

Can you tell me the syntax that can be used for mycompany/adminhtml/etc/config.xml
& The Module Entry XML in etc/module Folder

 
Magento Community Magento Community
Magento Community
Magento Community
 
R.
Jr. Member
 
Total Posts:  17
Joined:  2009-09-07
 

try

<global>
           <
blocks>
            <
adminhtml>
                <
rewrite>
                    <
permissions_user_edit_tab_main>NsName_ModuleName_Block_Adminhtml_Dashboard_Orders_Grid</permissions_user_edit_tab_main>
                </
rewrite>
            </
adminhtml>
        </
blocks>
   </global>
 
Magento Community Magento Community
Magento Community
Magento Community
 
Neo The Coder
Jr. Member
 
Avatar
Total Posts:  25
Joined:  2009-04-13
 

thanks for reply but i guess you are going wrong ; the class i have to override is below

class Mage_Adminhtml_Block_Permissions_User_Edit_Tab_Main extends Mage_Adminhtml_Block_Widget_Form

and the new Class Should be

class MyCompany_Adminhtml_Block_Permissions_User_Edit_Tab_Main extends Mage_Adminhtml_Block_Permissions_User_Edit_Tab_Main

& The Middle Code Reflects the Class you want to override the core class.

isn’t that true? So i think the new Code Should be Like

<global>
           <
blocks>
            <
adminhtml>
                <
rewrite>
                    <
permissions_user_edit_tab_main>MyCompany_Adminhtml_Block_Permissions_User_Edit_Tab_Main</permissions_user_edit_tab_main>
                </
rewrite>
            </
adminhtml>
        </
blocks>
   </global>
 
Magento Community Magento Community
Magento Community
Magento Community
 
R.
Jr. Member
 
Total Posts:  17
Joined:  2009-09-07
 

i have hoped you find yourself smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
Neo The Coder
Jr. Member
 
Avatar
Total Posts:  25
Joined:  2009-04-13
 

Sorry still in same situation anyone can help ? :-(

 
Magento Community Magento Community
Magento Community
Magento Community
 
R.
Jr. Member
 
Total Posts:  17
Joined:  2009-09-07
 

i gave you the solution ...

<?xml version="1.0"?>
<config>
    <
modules>
        <
NsName_ModuleName>
            <
version>0.1.0</version>
        </
NsName_ModuleName>
    </
modules>
   <global>
           <
blocks>
            <
adminhtml>
                <
rewrite>
                    <
permissions_user_edit_tab_main>NsName_ModuleName_Block_Adminhtml_Permissions_User_Edit_Tab_Main</permissions_user_edit_tab_main>
                </
rewrite>
            </
adminhtml>
        </
blocks>
   </global>
</
config>

your file Main.php have to be located in app/code/local/NsName/ModuleName/Block/Adminhtml/Permissions/User/Edit/Tab/Main.php

 
Magento Community Magento Community
Magento Community
Magento Community
 
aknal
Jr. Member
 
Total Posts:  1
Joined:  2010-05-13
 

I tried but still not working

I am not able to override Mage_Adminhtml_Block_Permissions_User_Edit_Tab_Main class

Main.php:

class MyMods_Adminhtml_Block_Permissions_User_Edit_Tab_Main extends Mage_Adminhtml_Block_Permissions_User_Edit_Tab_Main {

public function prepareForm() {

// my code
return Mage_Adminhtml_Block_Widget_Form::_prepareForm();
}
}

 
Magento Community Magento Community
Magento Community
Magento Community
 
raulsanchez
Sr. Member
 
Avatar
Total Posts:  83
Joined:  2011-02-22
 
aknal - 12 August 2011 08:11 PM



I tried but still not working

I am not able to override Mage_Adminhtml_Block_Permissions_User_Edit_Tab_Main class

Main.php:

class MyMods_Adminhtml_Block_Permissions_User_Edit_Tab_Main extends Mage_Adminhtml_Block_Permissions_User_Edit_Tab_Main {

public function prepareForm() {

// my code
return Mage_Adminhtml_Block_Widget_Form::_prepareForm();
}
}

Problem seems to be with your folder structure…

Modules should be in folder app/code/local, then a folder with the module company name, then a folder with the module name & then the code folders (such as Block, etc, Model...), as user R. said

From your class name it seems you are missing the module company name folder

Hope it helps
Best regards

 
Magento Community Magento Community
Magento Community
Magento Community
 
testveera
Jr. Member
 
Total Posts:  2
Joined:  2013-03-14
 

i’m trying the same with the api rolesedit.php to override the __construct method in that.

It not working for me.

My config file :
<?xml version="1.0"?>
<config>
<modules>
<Cmp_Test>
<version>0.1.0</version>
</Cmp_Test>
</modules>
<global>
<blocks>
<adminhtml>
<rewrite>
<api_tab_rolesedit>Cmp_Test_Block_Admihtml_Api_Tab_Main</api_tab_rolesedit>
</rewrite>
</adminhtml>
</blocks>
</global>
</config>

and my main.php:

class Cmp_Test_Block_Admihtml_Api_Tab_Main extends Mage_Adminhtml_Block_Api_Tab_Rolesedit {

public function __construct() {
parent::__construct();

$rid = Mage::app()->getRequest()->getParam(’rid’, false);

$resources = Mage::getModel(’api/roles’)->getResourcesList();

$rules_set = Mage::getResourceModel(’api/rules_collection’)->getByRoles($rid)->load();

$selrids = array();

foreach ($rules_set->getItems() as $item) {
if (array_key_exists(strtolower($item->getResource_id()), $resources) && $item->getApiPermission() == ‘allow’) {
$resources[$item->getResource_id()][’checked’] = true;
array_push($selrids, $item->getResource_id());
}
}

$this->setSelectedResources($selrids);

$this->setTemplate(’api/rolesedit.phtml’);
//->assign(’resources’, $resources);
//->assign(’checkedResources’, join(’,’, $selrids));
}
}

and module file :

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

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