tauren.kristich
tauren.kristich

Reputation: 479

Magento API in C# retrieve all order Items

I am having trouble Retrieving an order's item list.I can pull the order numbers, but not the products ordered.I am running The Magento API in C# visual Studio. My code lookes like this:

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();
    }

If you need anymore information, please let me know. Thank you in advanced!

Upvotes: 1

Views: 2143

Answers (1)

XodusMatthew
XodusMatthew

Reputation: 36

You need to iterate order.items...

foreach (salesOrderItemEntity OrderDetail in msoe.items){ ... }

Upvotes: 2

Related Questions