Search code examples
phpmagentomysqlilimitpager

how to send my sql to use magento pager


I have created a new database to give a list of custom order list

i give database to show with SQL code PS $sql is multiple line

  $sql = select * from database_name WHERE customfilter like $customfilter limit $startfrom, $limit
    $result = mysqli_query($cn,$sql)
    $collection = mysqli_fetch_array($result)

and I don't know which code to edit. i tried to edit code on product page to use in this page but it gives error.

Can anyone please suggest me which code to edit to use pager.

Below is the code that i tried

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

but it displays error.


Solution

  • Please have look on below code for product collection and setting the limit for page size.

    $collection  = Mage::getModel ('catalog/product')
                        ->getCollection()                       -
                        ->addAttributeToSelect('*')
                        ->setPageSize($this->getRequest()->getParam("limit"))
                        ->load();
    

    Please adopt customer collection page size from above and let me know.