【发布时间】:2011-05-11 06:19:06
【问题描述】:
在我自己的 Magento 扩展中,我使用网格块来显示我的数据库表中的数据集合。到目前为止一切正常,magento 的标准分页也可以。
我现在想将一些不在 db 表中的随机数据添加到集合中,以便在我的网格中显示它。如果我尝试按照分页停止工作:
class My_own_Block_Admin_Main_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
protected function _prepareCollection {
// Load the collection
$collection = getResourceModel('sales/order_grid_collection');
// Add custom data
$collection->addToAll('example', 'This is a test');
// Set the collection
$this->setCollection($collection);
return parent::_prepareCollection();
}
}
现在分页无效。第 1 页与第 2 页相同,显示所有条目。
在不破坏分页的情况下,将数据收集到集合的正确且有效的方法是什么?
【问题讨论】:
-
docs.magentocommerce.com/Mage_Page/… 也许寻呼机需要意识到你在堆栈中添加的集合的变化?
-
您应该接受您的答案(分数旁边的复选框会这样做),而不是将问题标记为“已解决”
标签: php collections magento grid pagination