Magento – Get Next and Previous item from a collection

collection;magento-1.9

Whats the best way to get the Next and Previous Item from a collection?

Best Answer

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()