I have something like this
foreach ($this->getProductCollection()as $prod) { ?>
.....
And I want to reverse the foreach loop so that it starts with the last product in the array.
Is there a quick way to do this?
You should use addAttributeToSort()
method of the Product Collection object before using it in a loop.
Something like that: //Correcting Misspellig, it was attAttribute $this->getProductCollection()->addAttributeToSort('attr_name', 'desc'); foreach ($this->getProductCollection() as $prod) { ... }
In place of addAttributeToSort
you can also use setOrder('fieldname', direction [asc/desc])