magento管理面板中的客户组排序返回错误

magento管理面板中的客户组排序返回错误,magento,magento-1.7,Magento,Magento 1.7,在我们的magento管理面板中,我们使用group列对客户进行排序 但它会显示带有错误的查询 这意味着当点击组列时,它会进入magento admin仪表板 所以,我们再次单击了ManageCustomers链接,但现在它显示查询错误 以下是出现错误的查询: SELECT `e`.*, `at_prefix`.`value` AS `prefix`, `at_firstname`.`value` AS `firstname`, `at_middlename`.`value` AS `middl

在我们的magento管理面板中,我们使用
group
列对客户进行排序

但它会显示带有错误的查询

这意味着当点击
列时,它会进入magento admin
仪表板

所以,我们再次单击了ManageCustomers链接,但现在它显示查询错误

以下是出现错误的查询:

SELECT `e`.*, `at_prefix`.`value` AS `prefix`, `at_firstname`.`value` AS `firstname`, `at_middlename`.`value` AS `middlename`, `at_lastname`.`value` AS `lastname`, `at_suffix`.`value` AS `suffix`, CONCAT(IF(at_prefix.value IS NOT NULL AND at_prefix.value != '', CONCAT(LTRIM(RTRIM(at_prefix.value)), ' '), ''), LTRIM(RTRIM(at_firstname.value)), ' ', IF(at_middlename.value IS NOT NULL AND at_middlename.value != '', CONCAT(LTRIM(RTRIM(at_middlename.value)), ' '), ''), LTRIM(RTRIM(at_lastname.value)), IF(at_suffix.value IS NOT NULL AND at_suffix.value != '', CONCAT(' ', LTRIM(RTRIM(at_suffix.value))), '')) AS `name`, `at_default_billing`.`value` AS `default_billing`, `at_billing_postcode`.`value` AS `billing_postcode`, `at_billing_city`.`value` AS `billing_city`, `at_billing_telephone`.`value` AS `billing_telephone`, `at_billing_region`.`value` AS `billing_region`, `at_billing_country_id`.`value` AS `billing_country_id`, `at_group_id`.`value` AS `group_id` FROM `customer_entity` AS `e`
 LEFT JOIN `customer_entity_varchar` AS `at_prefix` ON (`at_prefix`.`entity_id` = `e`.`entity_id`) AND (`at_prefix`.`attribute_id` = '4')
 LEFT JOIN `customer_entity_varchar` AS `at_firstname` ON (`at_firstname`.`entity_id` = `e`.`entity_id`) AND (`at_firstname`.`attribute_id` = '5')
 LEFT JOIN `customer_entity_varchar` AS `at_middlename` ON (`at_middlename`.`entity_id` = `e`.`entity_id`) AND (`at_middlename`.`attribute_id` = '6')
 LEFT JOIN `customer_entity_varchar` AS `at_lastname` ON (`at_lastname`.`entity_id` = `e`.`entity_id`) AND (`at_lastname`.`attribute_id` = '7')
 LEFT JOIN `customer_entity_varchar` AS `at_suffix` ON (`at_suffix`.`entity_id` = `e`.`entity_id`) AND (`at_suffix`.`attribute_id` = '8')
 LEFT JOIN `customer_entity_int` AS `at_default_billing` ON (`at_default_billing`.`entity_id` = `e`.`entity_id`) AND (`at_default_billing`.`attribute_id` = '13')
 LEFT JOIN `customer_address_entity_varchar` AS `at_billing_postcode` ON (`at_billing_postcode`.`entity_id` = `at_default_billing`.`value`) AND (`at_billing_postcode`.`attribute_id` = '30')
 LEFT JOIN `customer_address_entity_varchar` AS `at_billing_city` ON (`at_billing_city`.`entity_id` = `at_default_billing`.`value`) AND (`at_billing_city`.`attribute_id` = '26')
 LEFT JOIN `customer_address_entity_varchar` AS `at_billing_telephone` ON (`at_billing_telephone`.`entity_id` = `at_default_billing`.`value`) AND (`at_billing_telephone`.`attribute_id` = '31')
 LEFT JOIN `customer_address_entity_varchar` AS `at_billing_region` ON (`at_billing_region`.`entity_id` = `at_default_billing`.`value`) AND (`at_billing_region`.`attribute_id` = '28')
 LEFT JOIN `customer_address_entity_varchar` AS `at_billing_country_id` ON (`at_billing_country_id`.`entity_id` = `at_default_billing`.`value`) AND (`at_billing_country_id`.`attribute_id` = '27')
 LEFT JOIN `customer_entity_varchar` AS `at_group_id` ON (`at_group_id`.`entity_id` = `e`.`entity_id`) AND (`at_group_id`.`attribute_id` = '10') WHERE (`e`.`entity_type_id` = '1') ORDER BY `group_id` ASC LIMIT 20
当我们执行此查询phpmyadmin->SQL时,返回的错误如下:

#1052 - Column 'group_id' in order clause is ambiguous
那么我该如何解决这个问题呢

如果我的管理面板有任何问题

更新

这是我们添加的函数

D:\wamp\www\mysite\app\code\core\Mage\Adminhtml\Block\Customer\Grid.php

protected function _groupFilter($collection, $column){
        $this->getCollection()->getSelect()->where(new Zend_Db_Expr("{$this->getColumn()->getFilterIndex()} like '{$column->getFilter()->getValue()}'"));
        return $this;
    }

 protected function _prepareCollection()
    {
        $collection = Mage::getResourceModel('customer/customer_collection')
            ->addNameToSelect()
            ->addAttributeToSelect('email')
            ->addAttributeToSelect('created_at')
            ->addAttributeToSelect('group_id')
            ->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')
            ->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left')
            ->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
            ->joinAttribute('billing_region', 'customer_address/region', 'default_billing', null, 'left')
            ->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left');

        $this->setCollection($collection);

        return parent::_prepareCollection();
    }
\u prepareColumns()中添加此列

然后我得到了这个错误:

致命错误:对
D:\wamp\www\mysite\app\code\core\Mage\Adminhtml\Block\Customer\Grid.php第65行的非对象调用成员函数getFilterIndex()

这是日志文件中的错误:

2013-08-30T06:48:26+00:00 ERR (3): Warning: Missing argument 1 for Mage_Adminhtml_Block_Widget_Grid::getColumn(), called in D:\wamp\www\mysite\app\code\core\Mage\Adminhtml\Block\Customer\Grid.php on line 65 and defined  in D:\wamp\www\mysite\app\code\core\Mage\Adminhtml\Block\Widget\Grid.php on line 431
2013-08-30T06:48:26+00:00 ERR (3): Notice: Undefined variable: columnId  in D:\wamp\www\mysite\app\code\core\Mage\Adminhtml\Block\Widget\Grid.php on line 433

看起来您已经更改了默认的网格功能,如下面的SQl查询。它应该是
e`.`group\u id
,而不是
group\u id

希望这能帮助你

选择
e
*,
在前缀处
选择
作为
前缀
在名字处
作为
名字
在中间名处
作为
中间名
在名字处
作为
名字
at_suffix
value
AS
suffix
,CONCAT(IF(at_prefix.value不为NULL且at_prefix.value!=”,CONCAT(LTRIM(at_prefix.value)),“”,“”),LTRIM(at_firstname.value)),“”,IF(at_middlename.value不为NULL且at_middlename.value!=“”,CONCAT(LTRIM(RTRIM(at middlename.value)),“”),LTRIM(RTRIM(at_lastname.value)),如果(at_suffix.value不为空且at_suffix.value!='',CONCAT('',LTRIM(at_suffix.value)),'')作为
名称
作为默认计费
值作为
默认计费
作为默认计费
作为默认计费
值作为
计费
城市值作为
计费城市
电话
作为计费e,
在计费地区
值作为
计费地区
在计费国家id
值作为
计费国家id
作为
集团id
来自
客户实体
作为
e
在(
at\u prefix
entity\u id
=
e
e
entity\u id
)和(
at\u prefix
属性\u id
='4')上左键连接
customer\u entity\u varchar
左键连接(
at\u firstname
at\u-id
e
e
entity\u-id
)和(
at\u-firstname
属性\u-id
<5') 左键连接(
at\u middlename
实体id
=
e
实体id
实体id
和(
at\u middlename
属性id
<6')) 左键连接(
at'u lastname
at'u lastname
entity\u id
=
e
entity\u id
)和(
at'u lastname
属性\u id
=“7”) 左键连接
customer\u entity\u varchar
AS
at\u suffix
ON(
at\u suffix
entity\u id
=
e
实体\u id
)和(
at\u suffix
属性\u id
=“8”) 左键连接(
at\u default\u billing
at\u default\u billing
实体id
=
e
实体id
)和(
at\u default\u billing
属性id
='13') 左键连接(
at'u billing'u postcode
)上的
at'u billing'u postcode
实体id
=
at'u default'u billing
值)和(
at'u billing'u postcode
属性id
='30') 在(
在计费城市
在计费城市
实体id
=
在默认计费
和(
在计费城市
属性
='26')上左键加入
客户地址在计费电话处
在计费电话处
在计费电话处
上(
在计费电话处
实体id
=
在默认计费处
)和(
在计费电话处
属性id
='31') 在(
在计费区域
在计费区域
实体id
=
在默认计费区域
和(
在计费区域
属性
=28')上左键连接
客户地址at'u billing\u country\u id
实体\u id
at'u default\u billing
)和(
at'u billing\u country\u id
属性\u id
=27') 在(
at\u group\u id
at\u entity\u id
e
e
e
entity\u id
)和(
at\u group\u id
属性\u id
='10')上(
e
实体\u类型\u id
<1')按
e
e
顺序加入

您应该在列中添加以下内容:

$this->addColumn(
   'filter_index' =>'e.group'
)
为了进行筛选,如果仍不起作用,请尝试将其添加到列中:

$this->addColumn(...
    'filter_condition_callback' => array($this, '_groupFilter'),
     ...
)  

$this->addColumn(... 'filter_condition_callback' => array($this, '_groupFilter'), ... )

private function _groupFilter($collection, $column){
    $this->getCollection->getSelect()->where(new Zend_Db_Expr("{$this->getColumn()->getFilterIndex()} like '{$column->getFilter()->getValue())}'"));
    return $this;
}
public function getColumn($columnId)
{
    if (!empty($this->_columns[$columnId])) {
        return $this->_columns[$columnId];
    }
    return false;
}