【发布时间】:2011-03-11 11:28:20
【问题描述】:
我的目录/产品控制器中有一个最近的产品操作。
我检索所有按实体 ID 排序的产品。效果很好。
问题是我只想在 4 页中显示 20 个产品。
我尝试扩展Mage_Catalog_Block_Product_List 并覆盖_getProductCollection(),我做了这样的事情:
$this->_productCollection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSort('entity_id', 'desc')
->addStoreFilter();
还有最重要的部分:
$this->_productCollection->getSelect()->limit($this->getProductsLimit());
如果我“转储”返回的对象,我会有这样的结果:
["limitcount"] => int(5) ["limitoffset"] => int(0)
所以它看起来被分页器覆盖了。
你知道正确限制结果数量的方法吗?
对于优化和展示,我实际上并不想检索所有产品集合。
谢谢
【问题讨论】:
标签: php magento pagination