1

I am trying to rewrite a block for a module in the community code pool. The Module that I am trying to rewrite is TBT_Enhancedgrid. The directory structure is

app/code/community/TBT
└── Enhancedgrid
    ├── Block
    │   ├── Catalog
    │   │   ├── Product
    │   │   │   ├── Grid
    │   │   │   │   └── Columns.php
    │   │   │   └── Grid.php
    │   │   └── Product.php
    │   ├── System
    │   │   └── Html.php
    │   └── Widget
    │       ├── Grid
    │       │   ├── Column
    │       │   │   ├── Filter
    │       │   │   │   ├── Category.php
    │       │   │   │   └── Image.php
    │       │   │   └── Renderer
    │       │   │       ├── Action.php
    │       │   │       ├── Category.php
    │       │   │       └── Image.php
    │       │   └── Column.php
    │       └── Loyalty.php
    ├── controllers

app/code/local/Company/TBT/
└── EnhancedGrid
    ├── Block
    │   └── Widget
    │       └── Grid
    │           ├── Column
    │           │   └── Renderer
    │           │       └── Image.php
    │           └── Column.php
    └── etc
        └── config.xml

I am trying to re-write Column.php from the community module. The contents of the config file is

 <?xml version="1.0"?>
 <config>
 <modules>
     <Company_TBT_Enhancedgrid>
         <version>1.3.2.1</version>
     </Company_TBT_Enhancedgrid>
 </modules>
 <global>
     <blocks>
         <adminhtml>
             <rewrite>
<widget_grid_column>Company_TBT_Enhancedgrid_Block_Widget_Grid_Column</widget_grid_column>
            </rewrite>
        </adminhtml>
    </blocks>
</global>
</config>

The contents of the app/etc/module/Company_TBT_Enhancedgrid.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Company_TBT_Enhancedgrid>
        <active>true</active>
        <codePool>local</codePool>
        <depends>
            <TBT_Enhancedgrid/>
        </depends>
    </Company_TBT_Enhancedgrid>
</modules>

The Column.php file in local pool is

class Company_TBT_Enhancedgrid_Block_Widget_Grid_Column extends TBT_Enhancedgrid_Block_Widget_Grid_Column
{ 
       /* with contents*/
}

But the function defined in Image.php in local code pool is not being over-ridden. I did read the other related posting before posting this question, but I still can't figure out what am I doing wrong. Any help would be nice. Thanks

2

In magento, a module should have two level folders structure [ModuleNameSpace]>[ModuleName]

You have created three levels folder structure Company>TBT>Enhancedgrid

That seem to be wrong at magento.

SO you should change it to

Company>TBTEnhancedgrid from Company_TBT_Enhancedgrid

Now folder structure should be:

app/code/local/Company/
└── TBTEnhancedGrid
    ├── Block
    │   └── Widget
    │       └── Grid
    │           ├── Column
    │           │   └── Renderer
    │           │       └── Image.php
    │           └── Column.php
    └── etc
        └── config.xml

As the module structure change that you need to change Company_TBT_Enhancedgrid to Company_TBTEnhancedgrid at all file at your module.

Also your must change Company_TBT_Enhancedgrid.xml to Company_TBTEnhancedgrid.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Company_TBTEnhancedgrid>
        <active>true</active>
        <codePool>local</codePool>
        <depends>
            <TBT_Enhancedgrid/>
        </depends>
    </Company_TBTEnhancedgrid>
</modules>

Also , in magento rewrite a class not mean rewrite all class recursively under that rewrite class.

Suppose, you have rewrite the class TBT_Enhancedgrid_Block_Widget_Grid_Column not means rewrite TBT_Enhancedgrid_Block_Widget_Grid_Column_Renderer_Image

<global>
     <blocks>
         <enhancedgrid>
             <rewrite>
<widget_grid_column_renderer_image>Company_TBTEnhancedgrid_Block_Widget_Grid_Column_Renderer_Image</widget_grid_column_renderer_image>
            </rewrite>
        </enhancedgrid>
    </blocks>
</global>

Assume that enhancedgrid is block type of module TBT_Enhancedgrid

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.