我希望能够在Mage_Catalog_Block_Product_List_Toolbar块中迭代所有产品集合,忽略之前通过“setPageSize()”和“setCurPage()”设置的限制。我的方法如下所示:
/** @var Mage_Catalog_Block_Product_List_Toolbar $this */
//...
$collection = $this->getCollection();
// Remove the LIMIT and OFFSET parts from the generated SQL query:
$collection->getSelect()->reset(Zend_Db_Select::LIMIT_COUNT);
$collection->getSelect()->reset(Zend_Db_Select::LIMIT_OFFSET);
// Reload the collection using the new SQL query:
$collection->load();
foreach($collection as $product)
{
// ...
}
// ...
问题在于,集合似乎没有重新加载,因此之前设置的限制仍然存在。我错过了什么吗?集合被锁定或者其他原因导致不能更改吗?