関連するメソッド sales_order_invoice.create で遊んでいて、あなたと同じ問題に遭遇しました。何らかの理由で、請求書にコメントを含めると、サーバーに渡される引数の配列に余分な要素を挿入する必要があることがわかりました。
私はMagento EE版を実行しています。1.11.0.2 C# および XML-RPC.Net v2 ライブラリ (CookComputing.XmlRpcV2.dll) を使用してデータを Magento と統合します。
空の請求書のコメントが「0」であることに気づき、この解決策に出くわしました。これは、Send invoice on email (optional)
フィールドに入力していた値であり、コメントの前に空の要素を挿入してみることにしました。コメントは表示されましたが、アイテムはまだ請求されません。次に、アイテムのリストの前に空の要素を移動すると、すべてが機能しました。API /app/code/core/Mage/Sales/Model/Order/Invoice/Api.php のコードを確認しましたが、どこで、またはなぜそうなのかがわかりませんでした。私の唯一の推測は、XML-RPC リクエストを解析しているライブラリと関係があるということです。この呼び出しには他の引数の途中に配列があるため、何かが正しく取得されていません。
これを診断しようとして、私は XML-RPC ロガーを使用しました
logger = new RequestResponseLogger();
logger.Directory = "C:\Temp\";
magentoProxy.AttachLogger(logger);
logger.UnsubscribeFrom(magentoProxy);
次に、呼び出しに対する要求応答が何であるかを確認したいときはいつでも、これらの呼び出しを XML-RPC 呼び出しの前後に配置します
logger.SubscribeTo(magentoProxy);
// call to Magento that I want to see the XML for request and responses to
logger.UnsubscribeFrom(magentoProxy);
API 呼び出しのために Magento に送信された XML に問題はありませんでした。私が考えることができる唯一の他のことは、デバッガーが接続された状態でmagentoを起動し、Api.phpファイルまたはスタックがめちゃくちゃになる前にその作成メソッドに到達したときに何が起こるかを見ることですが、私はしませんでした.当時、Magento コードのアクティブなデバッグ用に開発環境をセットアップしていなかったので、今はその側面を掘り下げることに時間を費やしたくありませんでした。
私が回避策として行ったのは、Magento から order_info を再度取得し、注文のすべてのアイテムが請求されたかどうかを確認する請求書を作成するための呼び出しの後にいくつかのコードを追加することでした。エラー。ある時点で、この「バグ」またはこれが発生する原因となっているものが修正または変更された場合、少なくともこの呼び出しから請求される注文項目に影響があるかどうかがわかります.
// Get the order items that need to be invoiced
// this.orderInfo is the XmlRpcStruct returned from a sales_order.info call
XmlRpcStruct[] orderItems = this.orderInfo.Contains("items") ? (XmlRpcStruct[]) this.orderInfo["items"] : new XmlRpcStruct[] { };
XmlRpcStruct orderItemsToInvoice = new XmlRpcStruct();
Int32 orderItemId;
Int32 qtyOrdered;
Int32 qtyInvoiced;
Int32 qtyToInvoice;
foreach (XmlRpcStruct item in orderItems)
{
orderItemId = item.Contains("item_id") ? Convert.ToInt32(item["item_id"]) : 0;
qtyOrdered = item.Contains("qty_ordered") ? Convert.ToInt32(Convert.ToDecimal(item["qty_ordered"])) : 0;
qtyInvoiced = item.Contains("qty_invoiced") ? Convert.ToInt32(Convert.ToDecimal(item["qty_invoiced"])) : 0;
qtyToInvoice = qtyOrdered - qtyInvoiced;
orderItemsToInvoice[Convert.ToString(orderItemId)] = Convert.ToString(qtyToInvoice);
}
// Invoice This Order with a comment
String newInvoiceId = magentoProxy.salesOrderInvoiceCreate(sessionId: sessionId, arguments: new Object[] {
this.MageIncrementId, // Order increment ID
"", // this should not need to be here, but for some reason if I want to include a comment
// on the invoice I have to thave this extra empty element before the array of order items
// if no comment is included on the invoice this extra element is not needed, rather weird, I can not explain it.
orderItemsToInvoice, // array itemsQty Array of orderItemIdQty (quantity of items to invoice)
"Automatically invoiced prior to CounterPoint import." // Invoice Comment (optional)
//"0", // Send invoice on email (optional) defaults to false
//"0" // Include comments in email (optional) defaults to false
});
// Invoice This Order without a comment
String newInvoiceId = magentoProxy.salesOrderInvoiceCreate(sessionId: sessionId, arguments: new Object[] {
this.MageIncrementId, // Order increment ID
orderItemsToInvoice // array itemsQty Array of orderItemIdQty (quantity of items to invoice)
});