tags:

views:

17

answers:

1

I am getting the order information after the checkout process is finished and I saw something that is strange for me.

I use :

$orderItems = $order->getAllItems();

and for configurable products I get the Parent Tshirt for example and the Selected Medium Tshirt. So I get 2 items instead of 1.

How do I get only the selected products from an order object?

+1  A: 

What do you mean by "selected". They did select the parent product w/ options leading to the child? If you're looking for the parent item, look for the one with type_id of "configurable". If you want the child, you need the one with a parent_id which is not null.

I'll be happy to answer with code if you give more clarification.

Thanks, Joe

Joseph Mastey
I mean that you choose a T-shirt medium size with sku T_MEDIUM and getAllItems returns an array of two items on with sku TSHIRT for the configurable product and one T_MEDIUM for the actual product. What you suggested is what I have done but it seems a rather improper way of selecting the choosed product.
Elzo Valugi
It's certainly not optimal, but could you elaborate more on that you are looking to see? The all-items array will include both the T_MEDIUM and TSHIRT skus. When you encounter the TSHIRT sku, what do you expect to happen? When you encounter the T_MEDIUM sku afterwards, what do you expect to happen?Glad the solution at least works provisionally. :)Thanks,Joe
Joseph Mastey