How to List Orders by Order Status using Magento API

本文介绍如何使用SOAP和XML-RPC接口通过PHP脚本查询Magento中特定状态的订单列表。示例代码展示了如何登录到API并获取处于待处理状态的订单。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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();
}
?>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值