C#中的Magento API检索所有订单商品

时间:2012-06-29 14:06:10

标签: c# api magento

我在检索订单项目列表时遇到问题。我可以提取订单号,但不能订购产品。我在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();
    }

如果您需要更多信息,请告诉我们。 先谢谢你了!

1 个答案:

答案 0 :(得分:2)

你需要迭代order.items ......

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