【问题标题】:Adding data to Magento grid collection destroys pager将数据添加到 Magento 网格集合会破坏寻呼机
【发布时间】: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


【解决方案1】:

【讨论】:

  • 另外,如果解决方案很简单,你能把它贴在这里以便搜索者更容易找到吗? :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-10-23
  • 1970-01-01
  • 1970-01-01
  • 2013-11-08
  • 2023-04-04
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多