我想添加一个新的column
对位于这里的销售订单网格客户名称:的Magento - Magento中添加客户名称,以便电网1.7.0.2
App/code/local/Mage/Adminhtml/Block/Sales/Order/Grid.php
我要添加客户名称类似名称在管理客户。
我已经添加了下面的代码:
protected function _getCollectionClass()
{
return 'sales/order_grid_collection';
}
protected function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass());
/*junpeng add start*/
$collection->getSelect()
->join(
'customer_entity',
'main_table.customer_id = customer_entity.entity_id', array('email' => 'email'));
$collection->getSelect()->join(
'customer_entity_varchar',
'main_table.entity_id = customer_entity_varchar.entity_id', array('name' => 'value')
);
/*junpeng add end*/
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns()
{
$this->addColumn('name', array(
'header' => Mage::helper('sales')->__('Customer Name'),
'index' => 'name',
));
$this->addColumn('email', array(
'header' => Mage::helper('Sales')->__('Customer Email'),
'index' => 'email',
'type' => 'text',
));
}
客户电子邮件是确定的,但增加了客户名称不工作了!
有人可以帮我解决这个问题吗?
谢谢大家帮忙将这段代码
!我测试你的代码,然后有一个问题。如果对方没有登录,所有的信息将不会显示在您的代码中。 – 2013-04-28 14:51:07
@JasonCheng我对此表示怀疑。我们没有从客户会话中获得任何价值,所以这不是问题。这也适用于后端网格,因此客户的登录不在这里考虑。 – Kalpesh 2013-04-29 09:47:46
嗨kalpesh ..我在我的自定义模块网格中使用上面的代码,它给了我这个错误----列未找到:1054未知列'客户名'在'where子句',.....你知道我在哪里可能是错的。 – shashank 2016-02-09 05:18:49