0

I have wrote the pagination functionality,in the below code i set the pagination 4 for each page,but unfortunately i got all the records in first page itself,and even the second page also the entire records display, the only good thing is page size is working fine(i means page count). see the below code for better understanding.

block file code

class Federallawyer_Flpackage_Block_List extends Mage_Core_Block_Template {

    public function __construct() {
        parent::__construct();
        $collection =  Mage::getModel('flpackage/packages')->PackageCollection();
        //$collection->getSelect()->limit(4);
        //echo $collection->getSelect()->__toString(); exit;
        $this->setCollection($collection);
    }

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

    protected function _prepareLayout() {
        parent::_prepareLayout();
        $pager = $this->getLayout()->createBlock('page/html_pager', 'custom.pager');
        $pager->setAvailableLimit(array(4=>4)); //Now you can get 4 items in a page.
        $pager->setCollection($this->getCollection());
        $this->setChild('pager', $pager);
        $this->getCollection()->load();
        return $this;
    }
}

see the attached screens enter image description here

  • can you post the contents of PackageCollection method? – Marius Nov 5 '15 at 13:51
0

Maybe if you swap the limit and get collection lines on the pager? i.e.

$pager->setCollection($this->getCollection());
$pager->setAvailableLimit(array(4=>4)); //Now you can get 4 items in a page.

tho I'm not sure what this array(4=>4) does

  • array(4=>4) is nothing but use for per page count, then i tried the above code, still no positive response. – senthil Nov 5 '15 at 14:03
  • maybe try with setPageSize(4)? – Robin Nov 5 '15 at 14:10
  • even i tried with the above code but still no response. – senthil Nov 6 '15 at 4:29

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.