Friday, February 19, 2016

Magento admin change default page size of grid

You have to modify two files for that: Grid.php and Grid.phtml,
Below are the details of files:

In Admin Block File:
/public_html/app/code/core/Mage/Adminhtml/Block/Widget
Grid.php

Search for $_defaultLimit in the file and change the value according to your choice.
protected $_defaultLimit    = 75;

PHTML File:
app/design/adminhtml/default/default/template/widget
grid.phtml

Add your option in the select box.

<select name="<?php echo $this->getVarNameLimit() ?>" onchange="<?php echo $this->getJsObjectName() ?>.loadByElement(this)">
<option value="20"<?php if($this->getCollection()->getPageSize()==20): ?> selected="selected"<?php endif; ?>>20</option>
<option value="30"<?php if($this->getCollection()->getPageSize()==30): ?> selected="selected"<?php endif; ?>>30</option>
<option value="50"<?php if($this->getCollection()->getPageSize()==50): ?> selected="selected"<?php endif; ?>>50</option>
<option value="75"<?php if($this->getCollection()->getPageSize()==75): ?> selected="selected"<?php endif; ?>>75</option>
<option value="100"<?php if($this->getCollection()->getPageSize()==100): ?> selected="selected"<?php endif; ?>>100</option>
<option value="200"<?php if($this->getCollection()->getPageSize()==200): ?> selected="selected"<?php endif; ?>>200</option>
</select>

I have added 75 as additional page size, It will be default pagesize too.