1 Comment

Magento pagination not working with custom objects

Magento2 factory object inject parameters
Adding jQuery to static block

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.

Related Posts

  • json encode fetch null values in magento API (0)
    I need to convert the array value into json, but while converting to json it fetch null rows here is my original code which fetch 1500 values $proxy = new SoapClient('http://www.magentohost.in//api/v2_soap/?wsdl'); $sessionId = $proxy->login('apikey', 'password'); $result = […]
  • getting serialized data of a product object in magento (1)
    I am trying to ensure that at checkout all the data about the customer order is sent to our server using the POST rest API, However the product object is very complicated and using json_encode() on it, strips it down to only a couple of details. I would like to have all the details […]
  • getting serialized data of a product object in magento (1)
    I am trying to ensure that at checkout all the data about the customer order is sent to our server using the POST rest API, However the product object is very complicated and using json_encode() on it, strips it down to only a couple of details. I would like to have all the details […]
  • How to get order_increment_id using SOAP API in Magento 2 (1)
    In Magneto 1, we get the 'order_increment_id' when we use the 'order_creditmemo.info' parameter in SOAP API. The same thing I want to fetch in Magento 2 SOAP API. But when I am trying to get order_increment_id by using 'salesCreditmemoRepositoryV1'. It does not return the […]
  • Magento 2 Rest api POST JSON TypeProcessor error (0)
    Have a problem with Magento2 rest APIs. I try to import some data to DB table im my module. I wrote rest api, that gets a JSON array and insert it in database table, but when i try to send this array cities.json: { "cities": [ { […]
  • Magento 2 Rest api POST JSON TypeProcessor error (0)
    Have a problem with Magento2 rest APIs. I try to import some data to DB table im my module. I wrote rest api, that gets a JSON array and insert it in database table, but when i try to send this array cities.json: { "cities": [ { […]
  • Pagination count and collection display issue for custom collection (2)
    I have displayed custom collection on my custom page. The issue i am facing is that pagination is supposed to limit the collection per page but here in frontend whole collection is displayed on one page and the page count shows as Items 1 to 20 of 20 Total for the collection count […]
  • Store data not set after load grid ui (1)
    I have created my own custom module. Entity like Block and Page of module cms. Everything ok. My form can save data to db. In my form i have field to set which store to belong. It like cms blog store implement. But after load, store data seem not set in grid Why it happen? In grid ui […]
  • uiComponent Form. How to show data from DB table (1)
    I'm trying to understand uiForm Component. I'm stucked in My module settings page. I created database table with settings in one row. And now I must to get default data and show them in Form. My main questions: How get data from table and show it in e.g. input field? What […]
  • uiComponent Form. How to show data from DB table (1)
    I'm trying to understand uiForm Component. I'm stucked in My module settings page. I created database table with settings in one row. And now I must to get default data and show them in Form. My main questions: How get data from table and show it in e.g. input field? What […]
Magento2 factory object inject parameters
Adding jQuery to static block

1 Comment on this article

  • User November 12, 2016

    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.

    Reply

Add a comment