rss
twitter
    Find out what I'm doing, Follow Me :)

Friday, May 14, 2010

Pin It

Widgets

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”.

Magento Admin Grid: how to change number of rows

First of all, make backup copies of your files.

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

01.<adminhtml>
02. <events>
03. <core_block_abstract_prepare_layout_before>
04. <observers>
05. <reward>
06. <class>grid/observer</class>
07. <method>applyLimitToGrid</method>
08. </reward>
09. </observers>
10. </core_block_abstract_prepare_layout_before>
11.
12. </events>
13. </adminhtml>

Step 2.
Create model class observer.php

01.class Inchoo_Grid_Model_Observer
02.{
03.
04. public function applyLimitToGrid(Varien_Event_Observer $observer)
05. {
06. $block = $observer->getEvent()->getBlock();
07. 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))
08. $block->setDefaultLimit(200);
09.
10. }
11.
12.}

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.

No comments:

Post a Comment