Magento – Getting The State History of an Order

ce-1.6.2.0orders

Is it possible to get the order state history of an order? I'm able to get the statuses using sales/order_status_history model.

$orderHistory = Mage::getModel('sales/order_status_history')->getCollection()
                ->addFieldToFilter('parent_id', $order->getId());

This only brings back the order status and comment (and a few other bits).

Is there any way I can get the state the order was in for each status? I can't see it stored anywhere other than in the order table but that's the current state.

Thanks in advance.

Best Answer

You can get the order status thru the history collection you define, to get the state of a status you can use:

 $statusCollection = Mage::getResourceModel('sales/order_status_collection')
 ->joinStates();

In this collection you can lookup the status and check the assigned state.