【问题标题】:Magento Change Order Status from REST API来自 REST API 的 Magento 更改订单状态
【发布时间】:2016-07-07 15:00:45
【问题描述】:
【问题讨论】:
标签:
c#
api
rest
magento
magento-1.9
【解决方案1】:
对于可能面临相同问题的任何人,我发现无法通过 REST API 更新订单状态(也就是添加销售订单评论)。您必须使用 SOAP API,而版本 2 使它变得最简单。
设置:
- 在 magento 中,创建一个 SOAP 角色和用户
- 将 SOAP v2 API 作为 Web 引用添加到您的 Visual Studio 项目
代码:
public void UpdateOrderStatus(string orderIncrementId, string newStatus, string comment = "")
{
// Init service with uri
var service = new MagentoSoap.MagentoService();
// Login - username and password (soap api key) of the soap user
string sessionId = service.login(Username, Password);
// Update order status
service.salesOrderAddComment(sessionId, orderIncrementId, newStatus, comment, 1, true);
}
【解决方案2】:
您可以使用 addComment 方法执行此操作,该方法还允许您将新订单状态指定为其参数之一。
$sku='100000003';
$orderStatus = 'Downloaded';
$comment = 'The order was successfully downloaded';
$sendEmailToCustomer = false;
$proxy->call($sessionId, 'sales_order.addComment', array($sku, $orderStatus, $comment, $sendEmailToCustomer));