<?php
class Varien_Data_Collection implements IteratorAggregate, Countable
{
/**
* Implementation of IteratorAggregate::getIterator()
*/
public function getIterator()
{
$this->load();
return new ArrayIterator($this->_items);
}
/**
* Retireve count of collection loaded items
*
* @return int
*/
public function count()
{
$this->load();
return count($this->_items);
}
}
$products = Mage::getModel('catalog/product')->getCollection();
//it creates ArrayIterator instance
foreach($products as $product)
{
}
?>