Magento – Pagination for catalog product list using SOAP V2 API

apimagento-1.9productssoap

I'm developing an Android app for e-commerce by accessing Magento's SOAP V2 API. I want to show all the products with image and info of all the products in Android.

I'm using catalogProductList SOAP V2 API to get products ID from Magento. From product ID's I need to get product images and other info. I can't to do all these things at once. So How can I restrict response of catalogProductList API to get first 10 or 20 products ID's and iterate through the response of SOAP?

Best Answer

You could use the filters for this call, and then use created_at to select a subset of products.

Try this:

$complexFilter->complex_filter = array(
    array(
        'key' => 'CREATED_AT',
        'value' => array('key' => 'from', 'value' => '2012-12-17 00:00:00')
    ), 
    array(
        'key' => 'created_at',
        'value' => array('key' => 'to', 'value' => '2013-01-21 12:02:02')
    ), 
);

I took this code from here: https://stackoverflow.com/a/22874035/1016425

You can also filter by other attribute like SKU or Id:

$filters->complexFilter = array(
    array( 'key' =>'sku', 'value' => array('lt'=>'03969999')),
    array( 'key' => 'sku', 'value' => array('gt'=>'03969000')),
);

Then you can handle the pagination in the app, of course you would need to know how many products you have and how many products you want to show per page. I don't know of any pagination solution out of the box for soap api.

Also you could use the REST api, or if you want create a controller and an action which takes parameters for pagination and implement it yourself and then return the results in json

Related Topic