我想添加一個新的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