I want to get Configurable child simple products from order items.How can I get child simple Product from the configurable product?
I want to fetch only simple product object which associated with configurable product in order items
Here is my code.I can not fetch together configurable product Id and its associated child simple product object.
echo "<pre>";
$items = $order->getAllItems();
foreach($items as $item){
print_r($item->getProduct());
}
Best Answer
Use
$order->getAllVisibleItems()
instead of$order->getAllItems()
Updated Answer
$order->getAllVisibleItems()
will return only configurable product. Then you can get the child items of configurable products using$item->getChildrenItems()
. This method (getChildrenItems()
) is defined inMage_Sales_Model_Order_Item
. So, the code will be