I am trying to display random testimonials, but due to magento cache the random is not working, i have to flush the cache each time to see the testimonials change, my code
public function getTestimonialsLast(){
$collection = Mage::getModel('testimonial/testimonial')->getCollection();
$collection->getSelect()->order(new Zend_Db_Expr('RAND()'));
$collection->addFieldToFilter('status',1);
$collection->setPageSize(5);
return $collection;
}
how can i make it work , how can i make it so that whenever the page is refreshed the collection is randomized. Any help is greatly appreciated. Thank you in advance,
One possibility is in the view file:
You can stop Magento from caching the block by adding a false parameter when you implement the block.
<?php echo $this->getChildHtml('testimonials', false) ?>
Because of
Method Summary
string getChildHtml ([string $name = ‘’], [boolean $useCache = true], [ $sorted = true])
Or you could add the cache lifetime to your testimonial class:
public function getCacheLifetime() { return null; }