簡體   English   中英

Magento通過REST API更改訂單狀態

[英]Magento Change Order Status from REST API

我正在通過C#ASP.NET MVC應用程序中的REST API與Magento Web應用程序(1.9.2.2版)“通信”。

該應用程序實質上是比薩的后端訂單流儀表板。 我需要顯示最新的訂單,並允許用戶在處理項目時檢查項目(以及其他事項)。

我能夠檢索訂單,產品,客戶等; 但需要能夠更新訂單狀態。 從我的研究看來,這可以通過添加訂單注釋來實現。

也就是說,我的問題如下:

  1. 是否只能通過Magento 1.9中的SOAP服務添加訂單注釋(從而更新訂單狀態)?
  2. 如果上述情況成立,我如何使用另一種安全方法來更新特定訂單的訂單狀態?

REST API上的文檔: http : //devdocs.magento.com/guides/m1x/api/rest/Resources/Orders/order_comments.html

對於可能面臨相同問題的任何人,我發現無法通過REST API更新訂單狀態(也稱為添加銷售訂單注釋)。 您必須使用SOAP API,而版本2使其最簡單。

設定:

  1. 在magento中,創建一個SOAP角色和用戶
  2. 將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);
}

您可以使用addComment方法來執行此操作,該方法還可以讓您將新訂單狀態指定為其參數之一。

$sku='100000003';
$orderStatus = 'Downloaded';
$comment = 'The order was successfully downloaded';
$sendEmailToCustomer = false;

$proxy->call($sessionId, 'sales_order.addComment', array($sku, $orderStatus, $comment, $sendEmailToCustomer));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM