I created a module that used a custom widget/grid/column for my admin grid to display a thumbnail image and everything worked. Now I need to create another module in the same project that does the same thing, but the image column will not work. It appears like its not even loading my new class, since it won’t execute any stmt I put into the file. I know its properly loading data, b/c if I change the type to text, then the correct info from the DB is populated into the field. But when I change to my new ‘image’ type the cell is empty. does anyone know why it wouldn’t be working?
ABT/Background/etc/config.xml << doesn’t work
<global>
....
<blocks>
<background>
<class>ABT_Background_Block</class>
</background>
<adminhtml>
<rewrite>
<widget_grid_column>ABT_Background_Block_Widget_Grid_Column</widget_grid_column>
</rewrite>
</adminhtml>
</blocks>
....
</global>
the module I copied to get me up and running has the exact same config setup, but yet it works fine
ABT/Feature/etc/config.xml << this works correctly
<global>
....
<blocks>
<feature>
<class>ABT_Feature_Block</class>
</feature>
<adminhtml>
<rewrite>
<widget_grid_column>ABT_Feature_Block_Widget_Grid_Column</widget_grid_column>
</rewrite>
</adminhtml>
</blocks>
....
</global>
Here’s what happening with Magento when you rewrite a class.
When Magento instantiates a Block class, it uses code something like the following
The
createBlockmethod is a factory. Magento uses the identifierto lookup which class should be instantiated. By default, that’s
When you create your rewrite, you’re telling Magento
This means that, for any given system, a class may only be rewritten once. In the code you’re showing above, you’re trying to rewrite the class twice. Only one of your rewrites will win.
The quick approach I’d take is to keep all your customizations in a single override class.
More generally, I try to avoid using rewrites if at all possible. They’re a powerful system, but should be using sparingly. I haven’t done much grid customizing, but the general approach I’d try to take would be to change the adminhtml layout to instantiate a new grid class from my custom module that extends an existing grid class, which in turn may use custom column classes.
More work up front, but once you’ve figured it out you can use the technique over and over again, and not worry abou conflicts from a rewrite.