将数据添加到 Magento 网格集合会破坏寻呼机
在我自己的 Magento 扩展中,我使用网格块来显示数据库表中的数据集合。到目前为止,一切工作正常,magento 的标准分页也可以工作。
我现在想将一些不在数据库表中的随机数据添加到集合中,以将其显示在我的网格中。如果我尝试如下操作,分页将停止工作:
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 页相同,显示所有条目。
在不破坏分页的情况下将数据添加到集合中的正确且有效的方法是什么?
in my own Magento Extension I'm using a grid block, to display the collection of data in my db table. Everything works fine so far and the standard pagination from magento works, too.
I now want to add some random data, which isn't in the db table, to the collection to show it in my grid. If I try as follow the pagination stops working:
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();
}
}
The pagination is effectless now. Page 1 is the same as 2 and shows all entries.
What's the right and working way to a data to the collection without breaking the pagination?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题的答案是以下线程
http://www.magentocommerce.com/板/viewthread/192232/#t239222
The answer to that is prolem is the following thread
http://www.magentocommerce.com/boards/viewthread/192232/#t239222