在目录产品列表中,我可以在产品系列上使用shuffle(),但它只会减掉全集合(数百)的小比例(例如10)。此页面上还有无限的Ajax滚动。在滚动加载之前,随机的产品是第一个'页面'上的产品。

$_productCollection=$this->getLoadedProductCollection();
....
$items = $_productCollection->getItems();
shuffle($items);
foreach ($items as $_product):
....
.

有没有办法,我可以保留滚动功能,但是随机播放完整的集合?

一种抽搐所有产品的方法是下面的,但这需要一个装载的年龄,没有滚动。

$_productCollection = $this->getLoadedProductCollection();
$_productCollection->clear();
$_productCollection->setPage(1,99999);
.

有帮助吗?

解决方案

我认为你可以更好地添加这样的线:

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

这随机提交集合。但不是像洗牌一样的外部(只是混洗阵列)

许可以下: CC-BY-SA归因
scroll top