问题描述
我需要获取$collection->setPage(0, 10);
才能在我的非EAV模型上工作,并且它不起作用.我试过了$matches->getSelect()->setPage(0, 10);
,但没有帮助.
I need to get $collection->setPage(0, 10);
to work on my non-EAV model and it doesn't work. I've tried and $matches->getSelect()->setPage(0, 10);
and it doesn't help.
推荐答案
setPage()
方法仅适用于Magento中基于EAV的集合,因为它是在Mage_Eav_Model_Entity_Collection_Abstract
类中定义的...
The setPage()
method only works for EAV based collection in Magento because it is defined in Mage_Eav_Model_Entity_Collection_Abstract
class...
public function setPage($pageNum, $pageSize)
{
$this->setCurPage($pageNum)
->setPageSize($pageSize);
return $this;
}
如您所见,它是一个不错的速记实用程序,可用于基于EAV的集合.对于非基于EAV的集合,您可以在集合类中创建自己的版本,或者在初始化集合时使用更详细的语法在客户端代码中设置页码和页面大小:
As you can see, its a nice shorthand utility that is available to EAV based collections. For your non EAV based collection you can create your own version of this in your collection class or use the more verbose syntax for setting the page number and size in your client code when initialising the collection:
$collection->setCurPage($pageNum)
->setPageSize($pageSize)
;
这篇关于如何在Magento的非EAV模型中使用setPage()进行分页/限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!