4

I am sure I am missing something obvious today, as I just cannot work this out.

I am doing a REST call, to get all customers, paged at 100 results per page (forced limitation of max allowed per page = 100, ref: Mage_Api2_Model_Resource::PAGE_SIZE_MAX = 100)

so simple enough to fetch each page using a page filter. ref: Get All customers from Magento using rest API

All good and well, but how do you know how many pages there are, or know when you have reached the last page?

I did a test, and when I reach the last page + 1, the result just seems to be the last page results.

Surely the test is not to check:

if current results == previous results = last page reached

Any thoughts appreciated.

1 Answer 1

2

I think that to work out if you are on the last page or not, you have to find out how many records there are in Magento then calculate how many pages there are depending on your page filter.

As far as I am aware (from looking at the REST documentation), there are no REST methods to return this in the API so you'll have to extend it on to add this to the REST API. I did something similar ages ago as an investigation into extending the Magento products REST API. I did this by implementing a whole new REST route so more of a separate custom API not directly related to the normal Magento catalog API. You could either follow this route and create a new custom Customer API or rewrite the existing API models to add this extra call in.

Details of how I approached it can be found at http://magepim.com/news/Extending-the-Magento-REST-API-part-1_13

Your Answer

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

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