5

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.

1
  • Did you already try to do some logging? Would be interesting to see what data arrives and what is executed. Commented Nov 1, 2014 at 10:28

2 Answers 2

3

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'
    )
);
1
1

You could use a complex filter to achieve this.

$array_filter = array('complex_filter' => array(
                            array(
                                    'key' => 'updated_at',
                                    'value' => array(
                                            'key' => 'from',
                                            'value' => '2016-07-28 09:46:34'
                                    ),
                            ),
                            array(
                                    'key' => 'updated_at',
                                    'value' => array(
                                            'key' => 'to',
                                            'value' => '2016-07-28 09:46:35'
                                    ),
                            ),
                    ));

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.