1

This is my XML from my module X:

<global>
        <blocks>
.......
            <namespaceY_moduleY>
                <rewrite>
                    <subscription_grid>NamespaceX_ModuleX_Block_Adminhtml_Subscription_Grid</subscription_grid>
                </rewrite>
            </namespaceY_moduleY>
        </blocks>
...

In my module X I want to rewrite a block from module Y . What am i doing wrong? I put a syntax error in my NamespaceX_ModuleX_Block_Adminhtml_Subscription_Grid and i don't get it. This is my block from module X:

class NamespaceX_ModuleX_Block_Adminhtml_Subscription_Grid extends NamespaceY_ModuleY_Block_Adminhtml_Subscription_Grid
{
asdasdsa
}
0

Magento rewrite a class using it object prefix not using [NameSpace]_[moduleName]

<namespaceY_moduleY>  <!-- it is wrong -, it should be block class prefix-->
    <rewrite>
        <subscription_grid>NamespaceX_ModuleX_Block_Adminhtml_Subscription_Grid</subscription_grid>
    </rewrite>
</namespaceY_moduleY>

In your question,You have use <namespaceY_moduleY>.but it should be block class prefix/identifier which in define at config.xml of your module.

If you have open the NamespaceY_ModuleY's config then on it's under <global><blocks>....</block></global> .you will found the block class prefix of identifier of block of that module

<global>
        .... 
        <blocks>
            <[This_Is_YOUR_IDENTIFIER]> <!--- This tag is called idenfier -->
                    <class>namespaceY_moduleY_Block</subscription_grid>
                </rewrite>
            </[This_Is_YOUR_IDENTIFIER]> 
        </blocks>
 .......    

So, you should use [This_Is_YOUR_IDENTIFIER] instead of namespaceY_moduleY at NamespaceX_ModuleX module config.xml

=======


What is Prefix of block of a module

Suppose, for those case,i have taken the example of Mage_Catalog. Let check the config.xml of this module.

And catalog is block class prefix/identifier for Mage_Catalog module

Please see the below.

<?xml version="1.0"?>
<config>
    <modules>
        <Mage_Catalog>
            .....
        </Mage_Catalog>
    </modules>
    .......
    <global>
        <models>
            <catalog> <!-- this catalog is model prefix of module Mage_Catalog module -->
                <class>Mage_Catalog_Model</class>
            </catalog>
        </models>
        <blocks>
            <catalog>  <!-- this catalog is block prefix of module Mage_Catalog module -->
                <class>Mage_Catalog_Block</class>
            </catalog>
        </blocks>
</config>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.