You can always look up an order in the repository using itâ€™s ID. But then you want to use the properties of this order object you will always be calling getPropertyValue and casting it to the type you expect.
A better and much simpler way is to look up the order using the OrderManager. Then you get a strongly typed Order object and donâ€™t have have to deal with the repository. Life has become a little easier. 🙂
OrderManager orderManager = getOrderManager; Order order = orderManager.loadOrder(orderId);
Now that you have the order you can also get the profile for that order.
RepositoryItem profile = getProfileTools().getProfileForOrder(order);
The loadOrder method invokes the whole Pipeline. Don’t you think it will be a heavy operation if I have to load n number of orders?
Yes it could be heavy to load N number of orders using the loadOrder method.
I guess it depends on what you want to do and why you want to do it.
My requirement is to calculate what is the total amount of all the orders on a particular day. When I say total I mean amount after shipping and tax and orders in complete state.
I can always write an RQL for this but do we have any such thing in OOB.
Since this would be part of a scheduled task loading all the orders for the day and summing it probably won’t be a big performance issue. But if you are concerned you could really optimize by using SQL and not even use the ATG API.
Hi i am new to ATG commerce, can any one kindly tell me that when an order object will be created and when an order object will be created for a gust user and when a order object will be created for logged in user.
kalyan, an order object is created whenever a user visits an ATG site. However it is not always persisted to the repository.
Check out this post.
Many Thanks Frank.
Hi, kindly tell me when the pricing will be invoked
Actually we have a problem with the loadOrder function from OrderManager… We thought that loadOrder refresh entiry the order structure from repository… But loggeds in a open session, we modify the shopping cart from another session (an mobile app) with a ATG webservice (additemtoorder)… Then from original session we load the order from orderManager but the order isn’t correctly been refreshed… because when we try to add to the order from the store we have an error…
It’s possible that the Order was not entiry refreshed??
Are you not seeing any InvalidVersionExceptions in the logs? My guess is that might be happening. Check out http://betweengo.kimplicity.com/2009/08/17/how-to-debug-an-invalidversionexception-from-updating-an-atg-order/.
Hope that helps,