Magento Admin Grid: how to change number of rows

2 Comments 1st MAR 2010 | Posted by Domagoj Potkoc in Magento

Magento Admin Grid: how to change number of rows

We had a request from our client, that we change default number of items in Magento admin grid. Now, this is very simple, when we know how to change it. Below you can see an example which uses magento observer model and event hocking “core_block_abstract_prepare_layout_before”.

First of all, make backup copies of your files.

Step 1.
This is example of event hocking, put it in config.xml

<adminhtml>
        <events>
            <core_block_abstract_prepare_layout_before>
    			<observers>
                    <reward>
                        <class>grid/observer</class>
                        <method>applyLimitToGrid</method>
                    </reward>
                </observers>
    		</core_block_abstract_prepare_layout_before>

        </events>
    </adminhtml>

Step 2.
Create model class observer.php

class Inchoo_Grid_Model_Observer
{

    public function applyLimitToGrid(Varien_Event_Observer $observer)
    {
    	$block = $observer->getEvent()->getBlock();
    	if(($block instanceof Mage_Adminhtml_Block_Widget_Grid) &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp; !($block  instanceof Mage_Adminhtml_Block_Dashboard_Grid))
    	$block->setDefaultLimit(200);

    }

}

It would be good that you make your own module and all put in it. I hope that you know how to make magento module.

If you like what you read, please share it.

  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Yahoo! Bookmarks
  • Reddit
  • Technorati
  • Twitter
  • StumbleUpon
  • LinkedIn
  • Netvibes
  • NewsVine
  • Sphinn
  • Tumblr
  • Posterous

To post code in comments, place your code inside [code] and [/code] tags.

There are 2 comments (Add Yours +)

Leave a Comment

Please wrap all source codes with [code][/code] tags.
Magento Design and Development | Magento SEO | iPhone Application Development Web Application Development with ZEND | WordPress Ecommerce | WordPress development
Sitemap

Inchoo - webappsolutions | 2009