Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 按列值分组_Php_Magento - Fatal编程技术网

Php 按列值分组

Php 按列值分组,php,magento,Php,Magento,我已经创建了一个自定义模块,并在管理网格中调用模块集合 protected function _prepareCollection() { Mage::setIsDeveloperMode(true); ini_set('display_errors', 1); $collection = Mage::getModel('mymodule/custom')->getCollection(); $this->setCollection($collec

我已经创建了一个自定义模块,并在管理网格中调用模块集合

protected function _prepareCollection()
  {
    Mage::setIsDeveloperMode(true);
    ini_set('display_errors', 1);
    $collection = Mage::getModel('mymodule/custom')->getCollection();
    $this->setCollection($collection);
    return parent::_prepareCollection();
  } 
我想在模块表中使用group by列值

我试过这个

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中的任何地方都没有使用它

有人能告诉我代码的问题或问题的解决方案吗

//试试下面的代码

$collection = Mage::getModel('mymodule/custom')->getCollection();
$collection->getSelect()->group('column_2');
请检查以下内容:

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();
} 

试试这个$collection=Mage::getModel('mymodule/custom')->getCollection()$collection->getSelect()->group('column_2');非常感谢@emiprotechnologiesvt.Ltd。你能告诉我当我使用这个$collection=Mage::getModel('mymodule/custom')->getCollection()->getSelect()->group('column_2')时,出现了什么问题吗;你能告诉我代码的问题吗?受保护函数prepareCollection(){Mage::setIsDeveloperMode(true);ini_set('display_errors',1);$collection=Mage::getModel('mymodule/custom')->getCollection()->getSelect()->group('column_2');$this->setCollection($collection);返回父级::prepareCollection();}