2

So I am trying to rewrite _prepareColumns() function in Mage_Adminhtml_Block_Cms_Page_Grid class.

I created a module with a config.xml:

<?xml version="1.0"?>
<config>
    <modules>
        <Jurgis_Gridrewrite>
            <version>0.0.1</version>
        </Jurgis_Gridrewrite>
    </modules>
    <global>
        <blocks>
            <adminhtml>
                <rewrite>
                    <Cms_Page_Grid>Jurgis_Gridrewrite_Block_Adminhtml_Cms_Page_Grid</Cms_Page_Grid>
                </rewrite>
            </adminhtml>
        </blocks>
    </global>
</config>

And app/code/local/Jurgis/Gridrewrite/Block/Adminhtml/Cms/Page/Grid.php:

<?php
class Jurgis_Gridrewrite_Block_Adminhtml_Cms_Page_Grid extends Mage_Adminhtml_Block_Cms_Page_Grid
{

    protected function _prepareColumns()
    {
        //content
    }

}
?>

(My rewrite works if I just place the Mage file in the local folder)

My module is active. I cannot spot my mistake.

2

Everything looks quite right as far as the code that is posted in the question.

  1. Firstly, see if the application has recognized your rewrite by using the below line of code. print_r(Mage::getConfig()->getNode()->xpath('//global//rewrite'));

  2. Make sure to use return parent::_prepareColumns(); at the end of the _prepareColumns method.

    protected function _prepareColumns()
    {
        ....../* Your content */
    
        return parent::_prepareColumns();
    }
    

If this piece of information does not help you, could you please post in the content of your _prepareColumns() method.


Answer : Cms_Page_Grid in the config.xml should be in lowercase letters.It should be cms_page_grid

3
  • Oh, thanks, that's a cool tool I wasn't aware of! Yes my rewrite is recognised. I will post my full method although as I said, it was working when I just place it in the local/Mage folder – Jurģis Toms Liepiņš Jul 9 '18 at 9:50
  • I did find my mistake- in the config.xml, in the rewrite declaration tag I wrote it as: Cms_Page_Grid but it should be all lowercase like: cms_page_grid. I accepted your answer because what you showed me made me realize the mistake, If you could add this in your answer for others to see, that would be great. – Jurģis Toms Liepiņš Jul 9 '18 at 9:56
  • 1
    Hope xpath tip helps you in the future. Appreciate the self-help you did. I updated my answer. – nikin Jul 9 '18 at 11:28

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.