How to Get Child Simple Product Object from Configurable Sales Order Items in Magento 1.9

magento-1.9order-items

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 in Mage_Sales_Model_Order_Item. So, the code will be

foreach($order->getAllVisibleItems() as $item) {
$childItems = $item->getChildrenItems();
echo "<pre>";
   foreach($item->getChildrenItems() as $item){
     echo $item->getProduct()->getId(); // child product Id
     print_r($item->getProduct()); // child product Object
   }
 }