cancel
Showing results for 
Search instead for 
Did you mean: 

XML RPC - orders list - how to filter by date or date range

Highlighted

XML RPC - orders list - how to filter by date or date range

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

$client = new SoapClient('https://www.mydomain.com/api/v2_soap/?wsdl=1');


$session = $client->login('xxxx', 'xxxx');

 

$params = array(array(
'filter' => array(
array(
'key' => 'store_id',
'value' => '4'
)
),
'complex_filter' => array(
array(
'key' => 'created_at',
'value' => array(
'key' => 'from',
'value' => '2015-03-28 00:00:00'
),
),
array(
'key' => 'created_at',
'value' => array(
'key' => 'to',
'value' => '2015-03-29 24:00:00'
),
),
)
));

 

$filter = array('filter' => array(
array('key' => 'store_id', 'value' => '4'),
array('key' => 'created_at', 'value' => '2015-03-28 00:00:00')
));


$result = $client->salesOrderList($session, $params);


var_dump($result);

?>

 

Please refer the code above, I am trying to get the orders on a day or in a date range. 

 

For a day, I tried with this code.

 

$filter = array('filter' => array(
array('key' => 'store_id', 'value' => '4'),
array('key' => 'created_at', 'value' => '2015-03-28 00:00:00')
));

 

 

This works if I give the exact created_at date with time. If I omit the time or give some random time, it is not showing any results.

 

I don't know   how to filter on date range also. I tried complex filter as above, but it is not working.  

 

Any help is highly appreciated.