Using Magento 188.8.131.52, I am trying to export all new orders and order items as follows:
$ orders = Mage::getModel('sales/order') ->getCollection() ->addAttributeToSelect('*') ->addAttributeToFilter('created_at', array('from' => $ date_from,'to' => $ date_to)) ->addAttributeToFilter('status', array('nin' => array('canceled', 'pending_payment', 'holded'))) ->load();
I want to loop through the orders
foreach($ orders as $ order) and within that loop I want to then loop through the products
foreach($ order['items'] as $ item))
I can’t figure out why this is returning multiple copies of the same order in the collection. The number of duplicate orders seems to correlate to the number of products in the order – so an order with 9 products purchased in it will have 9 duplicates in the collection.
It appears to me that I am loading the order items instead of the orders with item data within – although if this were the case, it doesn’t make sense to me that the whole order is being duplicated.
Any advice would be appreciated.