我对Magento很新,我在自定义集合上遇到分页问题。我将页面限制设置为5,但是,所有六个结果都显示(请参阅screenshot)。
public function __construct()
{
parent::__construct();
//............
$oItems = new Varien_Data_Collection();
foreach ($collection as $col) {
$order = Mage::getModel("sales/order")->load($col->getId());
$items = $order->getAllVisibleItems();
//Mage::log(count($items));
foreach($items as $item) {
$varienObject = new Varien_Object();
$varienObject->setName($item->getName());
$varienObject->setProductId($item->getProductId());
$varienObject->setProductOptions($item->getProductOptions());
$oItems->addItem($varienObject);
}
}
$this->setCollection($oItems);
}
protected function _prepareLayout()
{
parent::_prepareLayout();
$pager = $this->getLayout()->createBlock('page/html_pager', 'custom.pager');
$pager->setAvailableLimit(array(5=>5,10=>10,25=>25,'All'=>'All'));
$pager->setCollection($this->getCollection());
$this->setChild('pager', $pager);
$this->getCollection()->load();
return $this;
}
我知道我必须亲近,但我显然错过了一些东西。