1

我在检索订单的项目列表时遇到问题。我可以提取订单号,但不能提取订购的产品。我在 C# Visual Studio 中运行 Magento API。我的代码如下所示:

class Program
{
    //Mage_Api_Model_Server_V2_HandlerPortType handler = new Mage_Api_Model_Server_V2_HandlerPortType();
    static void Main(string[] args)
    {
        Mage_Api_Model_Server_V2_HandlerPortTypeClient handler = new Mage_Api_Model_Server_V2_HandlerPortTypeClient();
        try
        {
            //initiate connection
            string session = handler.login("tauren_SOAP", "test123");
            filters mf = new filters();

            /* expiriment to grab order items */
            string order_id = "";
            salesOrderListEntity[] soe = handler.salesOrderList(session, mf);
            foreach (salesOrderListEntity msoe in soe)
            {
                try
                {
                    order_id = msoe.increment_id;
                    Console.WriteLine("Order Id: " + order_id);
                    orderItemIdQty itm = new orderItemIdQty();
                    Console.WriteLine(itm.qty);

                    Console.WriteLine("-----------------------");
                }
                catch (Exception exp)
                {
                    Console.WriteLine(exp.ToString());
                }
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.ToString());
        }

        //prompt for exit
        Console.WriteLine("Finshed. Press Return to Exit...");
        Console.ReadLine();
    }

如果您需要更多信息,请告诉我。提前谢谢你!

4

1 回答 1

2

您需要迭代 order.items ...

foreach(msoe.items 中的 salesOrderItemEntity OrderDetail){ ... }

于 2012-07-09T20:50:07.593 回答