Palanikumar
Palanikumar

Reputation: 1746

Overriding already existing magento module adminhtml block

Im trying to add one more custom field in Amasty shopby module. For that I need to override adminhtml form. I created module for that but that doesnt overriding the existing module. I have to override "Amasty_Shopby_Block_Adminhtml_Filter_Edit_Tab_General" class. Here is my code.

Mycompany_Mymodule.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Mycompany_Mymodule>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Amasty_Shopby />
                <Amasty_Base />
            </depends>
        </Mycompany_Mymodule>
    </modules>
</config>

Mycompany/Mymodule/etc/config.xml

<config>
_____________
______________
    <global>
        <blocks>
            <adminhtml>
                 <rewrite>        <filter_edit_tab_general>Mycompany_Mymodule_Block_Adminhtml_Filter_Edit_Tab_General
                   </filter_edit_tab_general>
                 </rewrite>
            </adminhtml>
        </blocks>
    </global>
 ____________
-________________
</config>

Mycompany\Mymodule\Block\Adminhtml\Filter\Edit\Tab\General.php

public class Mycompany_Mymodule_Block_Adminhtml_Filter_Edit_Tab_General extends Amasty_Shopby_Block_Adminhtml_Filter_Edit_Tab_General
{
 _______________
___________
}

Upvotes: 1

Views: 2675

Answers (1)

Alexei Yerofeyev
Alexei Yerofeyev

Reputation: 2103

What you are trying to override right now is not Amasty block, but adminhtml/filter_edit_tab_general. So to rewrite Amasty_Shopby_Block_Adminhtml_Filter_Edit_Tab_General you need the following config:

<global>
    <blocks>
        <amshopby>
            <rewrite>
                <adminhtml_filter_edit_tab_general>Mycompany_Mymodule_Block_Adminhtml_Filter_Edit_Tab_General</adminhtml_filter_edit_tab_general>
            </rewrite>
        </amshopby>
    </blocks>
</global>

Upvotes: 3

Related Questions