Which of the following code samples will display products from a certain category in random order?

  • $_productCollection = Mage::getResourceModel(‘catalog/product_collection’); Mage::getModel(‘catalog/layer’)->prepareProductCollection($_productCollection); $_productCollection->getSelect()->order(‘rand()’);
  • $products = Mage::getModel(‘catalog/product’) ->getCollection() ->addAttributeToSort() ->addAttributeToSelect(‘*”) ->addCategoryFilter(Mage::getModel(‘catalog/category’)->load()); $products->getSelect()->order(new Zend_Db_Expr(‘RAND()’));
  • $products = Mage::getModel(‘catalog/product’) ->getCollection() ->addAttributeToSort(‘id’, ‘RAND()’) ->addAttributeToSelect(‘small_image’) ->addCategoryFilter(Mage::getModel(‘catalog/category’) ->load($catId));
  • $_productCollection = Mage::getResourceModel(‘catalog/product_collection’); Mage::getModel(‘catalog/layer’)->prepareProductCollection($_productCollection); $_productCollection->getSelect()->rand();

Тупой индус взял вопрос отсюда: