简体   繁体   English

$ collection-> setPage(0,5)返回magento 1.9中的所有产品

[英]$collection->setPage(0,5) returning all products in magento 1.9

I want to get products in 5 5 groups. 我想获得5 5组的产品。 I am using 我在用

$collection->setPage() method $ collection-> setPage()方法

but it always returns all products. 但它总是返回所有产品。

$Category = Mage::getModel('catalog/category')->load(12); 
$collection = $Category->getProductCollection();
$tot = $collection->setPage(0,5);
echo count($tot);

$collection = Mage::getModel('catalog/product')->getCollection();
$collection->getSelect()->limit(20); 

It always returns a total number of products from the list. 它总是返回列表中的产品总数。

I also used: 我还用过:

$collection = Mage::getModel('catalog/product')->load(12)->getCollection();
$collection->setPageSize(10);

How can I group the first five products in one array after 6th to 10th products in another array? 如何将一个阵列中的前五个产品组合到另一个阵列中的第六至第十个产品中?

Maybe my version of the solution can help you 也许我的解决方案版本可以为您提供帮助

$i = 1;
do{
    $Category = Mage::getModel('catalog/category')
    ->getCollection()
    ->setPageSize($page_length);
    $page1 = $collection->setCurPage(1)->load();
    foreach ($collection as $value) {
     //...
    }
    $collection->clear();
    $i++;
}while ($i <= 2);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM