Wednesday, 20 August 2014

add custom pagination on custom module in Magento

insert below code in blok file (app/code/local/Name_space/Yourmodule/Block/index.php)

<?php
protected function _prepareLayout()
    {
        parent::_prepareLayout();

        $pager = $this->getLayout()->createBlock('page/html_pager', 'custom.pager');
        $pager->setCollection($this->getCollection());
        $this->setChild('pager', $pager);
        $this->getCollection()->load();
       
        return $this;
    }

    public function getPagerHtml()
    {
        return $this->getChildHtml('pager');
    }
?>

//get pager in your page

<?php echo $this->getPagerHtml();?>

2 comments:

  1. Now working showing all prodcuts.

    ReplyDelete
  2. Thanks for the best blog.it was very useful for me.keep sharing such ideas in the future as well.this was actually what i was looking for,and i am glad to came here!
    magento development company in bangalore 

    ReplyDelete