我正在沟通'使用Magento Web应用程序(版本1.9.2.2)通过C#ASP.NET MVC应用程序中的REST API。
该应用程序基本上充当比萨饼的后端订单流量仪表板。我需要显示最新的订单,并允许用户在处理项目时检查这些项目(除其他外)。
我能够检索订单,产品,客户等;但需要能够更新订单状态。根据我的研究,似乎可以通过添加订单评论来实现。
那就是说,我的问题如下:
REST API文档:http://devdocs.magento.com/guides/m1x/api/rest/Resources/Orders/order_comments.html
答案 0 :(得分:1)
对于可能面临同一问题的任何人,我发现无法通过REST API更新订单状态(AKA添加销售订单评论)。您必须使用SOAP API,而版本2使它变得最简单。
<强>设定:强>
<强>代码:强>
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);
}
答案 1 :(得分:-1)
您可以使用addComment方法执行此操作,该方法还允许您将新订单状态指定为其参数之一。
$sku='100000003';
$orderStatus = 'Downloaded';
$comment = 'The order was successfully downloaded';
$sendEmailToCustomer = false;
$proxy->call($sessionId, 'sales_order.addComment', array($sku, $orderStatus, $comment, $sendEmailToCustomer));