Developer forum

Forum » Development » Order with parts list product

Order with parts list product

Rui Silva
Reply

Hi,

Can anyone please confirm if it's normal an order object having the Parts List in the OrderLines property?

I've executed the following lines in an immediate window and different behavior happens:

Order.GetOrders("select * from ecomorders where orderid = 'RS-ORDER1272'", false)[0].OrderLines;
Count = 5
    [0]: {Dynamicweb.eCommerce.Orders.OrderLine}
    [1]: {Dynamicweb.eCommerce.Orders.OrderLine}
    [2]: {Dynamicweb.eCommerce.Orders.OrderLine}
    [3]: {Dynamicweb.eCommerce.Orders.OrderLine}
    [4]: {Dynamicweb.eCommerce.Orders.OrderLine}
Order.GetOrderByID("RS-ORDER1272").OrderLines;
Count = 2
    [0]: {Dynamicweb.eCommerce.Orders.OrderLine}
    [1]: {Dynamicweb.eCommerce.Orders.OrderLine}

 

I would aspect to have the same result in both methods.

Best,

Rui Silva


Replies

 
Nicolai Pedersen
Reply

Hi Rui

It depends on the scenario. You call the GetOrders(SQL, preLoadOrderLines) overload with false in the second parameter, which is used in scenarios where we need to load all the information.

If you Load with True, you get the same result (and also lazy load of the orderlines).

I can see it is tricky behavior, but I do not think we can change it as it will break API behavior.

 
Rui Silva
Reply

Hi Nicolai,

Thanks for the fast reply, but you are not completely right. I've just repeated the test adding the suggestion you made and the preLoadOrderLines parameter does not affect the way the Order object is loaded.

See the new results below:

Order.GetOrders("select * from ecomorders where orderid = 'RS-ORDER1272'", true)[0].OrderLines;
Count = 5
    [0]: {Dynamicweb.eCommerce.Orders.OrderLine}
    [1]: {Dynamicweb.eCommerce.Orders.OrderLine}
    [2]: {Dynamicweb.eCommerce.Orders.OrderLine}
    [3]: {Dynamicweb.eCommerce.Orders.OrderLine}
    [4]: {Dynamicweb.eCommerce.Orders.OrderLine}
Order.GetOrders("select * from ecomorders where orderid = 'RS-ORDER1272'", false)[0].OrderLines;
Count = 5
    [0]: {Dynamicweb.eCommerce.Orders.OrderLine}
    [1]: {Dynamicweb.eCommerce.Orders.OrderLine}
    [2]: {Dynamicweb.eCommerce.Orders.OrderLine}
    [3]: {Dynamicweb.eCommerce.Orders.OrderLine}
    [4]: {Dynamicweb.eCommerce.Orders.OrderLine}
Order.GetOrderByID("RS-ORDER1272").OrderLines;
Count = 2
    [0]: {Dynamicweb.eCommerce.Orders.OrderLine}
    [1]: {Dynamicweb.eCommerce.Orders.OrderLine}

 

Best,

Rui Silva

 

 
Nicolai Pedersen
Reply

That is because of internal http request cache.

If you call GetOrders(sql, false) first, the output will look different.

 

You must be logged in to post in the forum