是的,这是可能的,但是当您尝试应用过滤器时会遇到问题(例如按价格从低到高排序等)
我认为更好的方法是按日期随机化,这样每个人都会在给定的一天获得相同的产品订单。
下面是我用来在标签页面上显示特定类别的随机产品的伪代码示例。(你可以改变$seed
来完成你想要的)
public function _getProductCollection()
{
if(is_null($this->_productCollection)) {
$category = Mage::getModel('catalog/category')->load($this->getCategoryId());
$seed = $this->getCategoryId() . date("W");
$this->_productCollection = Mage::getResourceModel('catalog/product_collection');
Mage::getModel('catalog/layer')->prepareProductCollection($this->_productCollection);
$this->_productCollection->getSelect()->order("rand($seed)");
$this->_productCollection->addStoreFilter();
$this->_productCollection->addCategoryFilter($category);
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($this->_productCollection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($this->_productCollection);
}
return $this->_productCollection;
}