magento get products from category, order by rand()

后端 未结 3 461
别跟我提以往
别跟我提以往 2020-12-25 14:02

I have the following:

$products = Mage::getModel(\'catalog/product\')
    ->getCollection()
    ->addAttributeToSort(\'id\', \'RAND()\')
    ->addAt         


        
3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-25 14:56

    Refer to this question: query magento limit + order by rand() and clockworkgeek's answer:

    $collection->getSelect()->order(new Zend_Db_Expr('RAND()'));
    

提交回复
热议问题