2017-07-06 174 views
0

我创建了一个自定义模块,并在管理网格中调用模块集合。按列值分组

protected function _prepareCollection() 
    { 
    Mage::setIsDeveloperMode(true); 
    ini_set('display_errors', 1); 
    $collection = Mage::getModel('mymodule/custom')->getCollection(); 
    $this->setCollection($collection); 
    return parent::_prepareCollection(); 
    } 

我想在我的模块表中的列值,使用组..

我想这

protected function _prepareCollection() 
     { 
     Mage::setIsDeveloperMode(true); 
     ini_set('display_errors', 1); 
     $collection = Mage::getModel('mymodule/custom')->getCollection()->getSelect()->group('column_2'); 
     $this->setCollection($collection); 
     return parent::_prepareCollection(); 
     } 

,但它不工作,它抛出一个错误

Unrecognized method 'setPageSize()' 

其中我没有在我的grid.php中使用任何地方

有人可以提出我的问题,我的代码或我的问题的解决方案

+0

试试这个.. $集合=法师:: getModel( 'mymodule中/自定义') - > getCollection(); $ collection-> getSelect() - > group('column_2'); –

+0

非常感谢@ EmiproTechnologiesPvt.Ltd。你可以告诉我什么是问题,当我使用这个 $ collection = Mage :: getModel('mymodule/custom') - > getCollection() - > getSelect() - > group('column_2'); –

回答

0

//尝试使用下面的代码。

$collection = Mage::getModel('mymodule/custom')->getCollection(); 
$collection->getSelect()->group('column_2'); 
1

检查与此:

protected function _prepareCollection() 
{ 
    Mage::setIsDeveloperMode(true); 
    ini_set('display_errors', 1); 
    $collection = Mage::getModel('mymodule/custom')->getCollection(); 
    $collection->getSelect()->group('column_2'); 
    $this->setCollection($collection); 
    return parent::_prepareCollection(); 
} 
+0

你能告诉我我的代码有问题吗?保护函数_prepareCollection() { Mage :: setIsDeveloperMode(true); ini_set('display_errors',1); ('column_2');}}收集=法师:: getModel('mymodule /定制') - > getCollection() - > getSelect() - >组('column_2'); $ this-> setCollection($ collection); return parent :: _ prepareCollection(); } –