I'm dealing with a Magento Store (CE 1.7) that has over 10M orders.
I am trying to get the full order list through SOAP V1 in order to extract some statistics from it, and i encounter the following problem.
When i run
$result = $soap->call($session_id, 'sales_order.list', array(array('status'=>array('eq'=>'Canceled'))));
echo "<pre>";
foreach($result as $order){
echo ($order['increment_id'])." - "; // order number
echo ($order['customer_id'])." - "; // customer number
echo ($order['billing_lastname'])." - "; // customer last name
echo ($order['grand_total']); // grand Total
echo "<br/>";
}
echo "</pre>";
i sucessfuly get the results (~ 1300 records).
When i try to change 'Canceled' to 'Processing', or 'eq' to 'neq' (expecting about 10M results) i get an error Warning: Invalid argument supplied for foreach()
and if i print_r($result);
i get an empty string.
Best Answer
The only solution is to process records in batches. Use order ID range in your filter along with filter by status (make sure to use 'from' and 'to' filters for range, since these are the only filters that can be applied to the same field in one request). This is not possible with SOAP V1, so my suggestion is to use SOAP V2. Filter should look something like:
Send multiple requests with different order ID range, then Magento will be able to generate response without exceeding memory limit.