Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

random сортировка коллекции
 
alesto
Guru
 
Total Posts:  624
Joined:  2009-03-21
 

Нашёл по буржуйским веткам форума много примеров. Но почему то не 1 не заработал :( есть вот такой вот код

$cat=Mage::getModel('catalog/category')->load($id);
$myproducts=$cat->getProductCollection()->setOrder('name''asc');
$myproducts->addAttributeToFilter('tire_manufacturer',$_product->getTire_manufacturer());
$myproducts->addAttributeToFilter('tire_season',$_product->getTire_season());
$myproducts->exportToArray();

И как сделать чтобы $myproduct сортировался случайным образом?

 
Magento Community Magento Community
Magento Community
Magento Community
 
varyous
Sr. Member
 
Total Posts:  221
Joined:  2008-10-18
Russia
 

вместо

->setOrder('name''asc')
нужно написать что-то вроде
$collection->getSelect()->order('rand()');
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top