Magento-RestApi
Magento-RestApi copied to clipboard
Download Orders Limit
So I'm trying to download all of the currently stored orders from the Magento database, but am only able to get either the first, or last 100 orders:
I've created a filter for the request where I set the Page to 0, the page size to 100 (maximum allowed) and specified the sort field as "entity_id".
So, with that done, if I set the sort order ascending, I get the first 100 orders of the database, and if I set the order to descending I get the last 100 orders. The question is, in either case, how do I get the NEXT 100 orders? I've tried incrementing the filter.Page attribute inside a do...while() loop, but every subsequent request still only captures the same 100 elements as the original request...
So what am I missing? / doing incorrectly?
Thanks!
Code:
private async void LoadMagentoOrders()
{
Magento.RestApi.Models.Filter orderFilter = new Magento.RestApi.Models.Filter();
orderFilter.Page = 0;
orderFilter.PageSize = 100;
orderFilter.SortField = "entity_id";
orderFilter.SortDirection = Magento.RestApi.Models.SortDirection.desc;
MagentoApiResponse<IList<Magento.RestApi.Models.Order>> orders;
do
{
orderFilter.Page++;
orders = await BEL.Magento.GetOrders(orderFilter);
if (!orders.HasErrors && (orders.Result.Count > 0))
this._magentoOrders.LoadRestOrders(orders.Result.ToArray(),false);
} while (!orders.HasErrors && (orders.Result.Count > 0));
this._magentoOrders.RefreshDGV(); // Update the DGV
}
On this page: [https://github.com/magento/magento2/issues/3787]
The call appears to be made using the parameter "currentPage=", whereas this API places the call using just "page="...
orders?searchCriteria%5BcurrentPage%5D=100&searchCriteria%5BpageSize%5D=100
orders?page=141&limit=100&order=entity_id&dir=desc
Could this be the problem? I'm having a helluva time trying to find detailed documentation on this stuff; also, as I only have VS-Pro 2013 which cannot compile the API, so I can't easily just change it and see what happens... :(