嗨,当使用Mage :: getResourceModel在magent中获取资源模型时,我可以添加过滤器没有问题,但是如何将结果集限制为5或10?
Assuming you're talking about Magento Collections, the ORM uses a paging style interface to limit things. You tell the collection how big you want each page to be ( setPageSize
), then you tell it which page you want to be on ( 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行)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.