Magento - 显示随机的推荐

时间:2014-06-26 10:00:27

标签: magento-1.8

我需要在主页上随机显示推荐信

$collection = Mage::getModel('turnkeye_testimonial/testimonial')->getCollection();   
foreach($collection as $testimonial)
{
   /My Div
}

我该怎么办?

1 个答案:

答案 0 :(得分:1)

$collection=Mage::getModel('turnkeye_testimonial/testimonial')->getCollection();
 $collection->getSelect()->order('rand()');
$collection->setPage(1, $numProducts);
foreach($collection as $testimonial)
{
   /My Div
}