近期在做的一个Magento网站,客户要求在后台订单列表里增加一列,用来显示用户的公司名称,在Magento1.7.0.2上测试通过,代码步骤如下: 1、打开app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php 2.将如下函数
protected function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass());
$this->setCollection($collection);
return parent::_prepareCollection();
}
替换为
protected function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass());
$collection->getSelect()->join('sales_flat_order_address', 'main_table.entity_id = sales_flat_order_address.parent_id',array('company'));
$this->setCollection($collection);
return parent::_prepareCollection();
}
3.搜索函数:protected function _prepareColumns() 该函数是用来显示列表名称的,在适当的位置增加如下代码:
$this->addColumn('billing_name', array(
//'header' => Mage::helper('sales')->__('Bill to Name'),
'header' => Mage::helper('sales')->__('Company Name'),
'index' => 'billing_name',
));
(责任编辑:最模板) |