Whats the best way to get the Next and Previous Item from a collection?
2 Answers
To Get Next and Previous item from a collection you need to Iterate collection object
For Example
foreach($collection as $_collection){
print_r($_collection->getData())
}
If you want to get only first or last item from collection,methods are available for that:
$collection->getFirstItem() and $collection->getLastItem()
Collection itself
As Minesh pointed out indirectly: There is no way using the API of the colletion directly.
The problem is, that magento only implements IteratorAggregate, so the Collection itself doesn't offer what you want.
The Iterator is an ArrayIterator
public function getIterator()
{
$this->load();
return new ArrayIterator($this->_items);
}