Magento – SOAP v2 API occasionally ignores filters

apifiltersoap

I'm using the SOAP v2 API to pull a list of orders with the following filters:

$params = array(
    array('key' => 'state', 'value' => 'processing')
);
$complex_params =array(
    array('key'=>'created_at','value'=>array('key' =>'from','value' => $dateFrom)) // GMT
);
$orders = $this->client->salesOrderList($this->session, array('filter' => $params, 'complex_filter' => $complex_params));

This works 95% of the time. Once every couple of days the API will ignore the date range and state filters and return all the orders. This can cause problems as it will return all orders! It returns so many orders with some stores that it hits my PHP memory limit.

Has anyone else run into this before? Is there anything that can be done (other than raise the PHP memory limit)?

Follow up:

I never found a consistent solution to this. I've communicated with many different Magento installations over the years and only some had this issue but I was never able to pinpoint the root cause. For Magento I just always double check the result data.

Best Answer

You could try using the filters array as follows. I think this should allow you to filter by two dates

$filters = array(
    'created_at' => array(
        'from' => '2015-01-01 01:00:00',
        'to' => '2015-01-31 02:22:00'
    )
);