[英]Magento resource model filter and limit
嗨,當使用Mage :: getResourceModel在magent中獲取資源模型時,我可以添加過濾器沒有問題,但是如何將結果集限制為5或10?
假設您在談論Magento集合,那么ORM使用分頁樣式界面來限制事物。 您告訴集合您希望每個頁面多大( setPageSize
),然后告訴它要放在哪個頁面上( setCurPage
)。
//same as, and "better" than Mage:getResourceModel('catalog/product_collection');
Mage::getModel('catalog/product')
->getCollection()
->setPageSize(10)->setCurPage(1); //first 10 items
Mage::getModel('catalog/product')
->getCollection()
->setPageSize(10)->setCurPage(2); //second 10 items
///etc...
$select->limit(5)
檢查app/core/mage/Catalog/Model/Resource/Eav/Mysql4/Url.php
的_getProducts()
方法(第806行)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.