我正在尝试向 Magento 的销售订单网格(管理员 > 销售 > 订单)添加一个新列。我尝试按照此处的说明进行操作:http: //www.atwix.com/magento/customize-orders-grid/
我已将核心文件复制到本地文件夹,以便可以覆盖它:
来自:/public_html/wholesale/app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php
收件人:/public_html/wholesale/app/code/local/Mage/Adminhtml/Block/Sales/Order/Grid.php
奇怪的是,无论我对 EITHER 文件进行什么更改,管理端都没有任何变化。我什至无法让 Mage::log() 工作。
一旦我解决了这个问题,我需要确保我所做的更改是正确的。我只是想获取客户的公司名称。这是我添加的两个部分:
protected function _prepareCollection()
{
// This line is from the original
$collection = Mage::getResourceModel($this->_getCollectionClass());
// This is the call where I try to bring in the extra field
// from another sales table
$collection->getSelect()->join(
'sales_flat_order_address',
'sales_flat_order.entity_id = sales_flat_order_address.parent_id',
array('company')
);
// These lines are also default
$this->setCollection($collection);
return parent::_prepareCollection();
}
在 _prepareColumns() 中:
$this->addColumn('company', array(
'header' => Mage::helper('sales')->__('Company'),
'index' => 'billing_company',
));
仅供参考,我正在使用 Magento 1.7.0.2