0

I am trying to applying magento pagination on custom object but not able to do it properly. Problem is my object is not an db object, I am calling an API which returns data in json format. I am converting the data into array first and then trying to convert that array into collection object. The pager calculates the page numbers correctly. It seems like it is not able to apply limits on the collection. All the items show on all the pages. This is how i am doing it -

$collection = new Varien_Data_Collection();
foreach($order['data']['orderlist'] as $row){
    $rowObj = new Varien_Object();
    $rowObj->setData($row);
    $collection->addItem($rowObj);
}

Please let me know how can i apply the limits correctly on each page. Any help would be much appreciated.

1 Answer 1

2

once the elements are loaded there is no way to paginate them, because when you later go through foreach ($collection as $item) you iterate through all the items.
If you want a pagination in this case you should determine the current page and the items that should be displayed before adding them to the collection and then just add the ones you need.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.