we can select random rows from MySQL table using Zend_Db_Expr(‘RAND()’),
here we have to create a new function in module collection class
(Namespace/Module/Model/Mysql4/Module/Collection.php)
public function setRandomOrder()
{
$this->getSelect()->order(new Zend_Db_Expr('RAND()'));
return $this;
}
And use it as
$collection = Mage::getModel('test/test')
->getCollection()
->setRandomOrder();
Congratulations for this nice looking blog. In this post everything about Web Development. I am also interested in latest news
ReplyDeleteThanks
Magento Modules