How to List Orders by Order Status using Magento API

SOAP

<?php
$soapclient = new SoapClient('');
$sessionId = $soapclient->login('YourAPIUser', 'YourAPIKey'); 
// Webservice User and API Key
// Getting Order listing by Order Status
// Example Usage:  array('eq' => 'canceled') , array('eq' =>'processing'),array('eq' => 'complete')
try {
$orders = $soapclient->call($sessionId, 'sales_order.list',
array(array('status' => array('eq' => 'pending'))));
foreach ($orders as $order) {
echo "OrderId:" . $order['order_id'] . "
";
}
} catch (Exception $fault) {
echo $fault->getMessage();
}
?>

 XMLRPC Example:

<?php
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
umask(0);
Mage::app();
$xmlrpcclient = new Zend_XMLRPC_Client('http://example.com/api/xmlrpc/');
$session = $xmlrpcclient->call('login', array('YourAPIUser', 'YourAPIKey'));
try {
$orders = $xmlrpcclient->call('call', array($session, 'sales_order.list', array(array('status' => 'canceled'))));
foreach ($orders as $order) {
echo "OrderId:" . $order['order_id'] . "
";
}
} catch (Exception $fault) {
echo $fault->getMessage();
}
?>

猜你喜欢

转载自wuchengyi.iteye.com/blog/1935919
今日推荐