您基本上需要编辑资源模型以包含您想要包含的字段。您可以在代码中编辑资源,我不确定您使用的是什么版本,但在 Grid.php 文件中您会看到 _prepareCollection 找到类似的代码,
$collection = Mage::getResourceModel('sales/order_invoice_collection')
->addAttributeToSelect('order_id')
->addAttributeToSelect('increment_id')
->addAttributeToSelect('created_at')
->addAttributeToSelect('state')
->addAttributeToSelect('grand_total') ...and so on!
添加行
->addAttributeToSelect('tax_amount')
到那个列表,你应该可以使用
$this->addColumn('tax_amount', array(
'header' => Mage::helper('sales')->__('Tax'),
'index' => 'tax_amount',
'type' => 'number',
));
这就像我离开我的开发机器并且手头没有法师一样未经测试,但这应该可以工作,或者至少可以为您指明正确的方向。
编辑:
如果您无法尝试更换整个 _prepareCollection
protected function _prepareCollection()
{
$collection = Mage::getResourceModel('sales/order_invoice_collection')
->addAttributeToSelect('order_id')
->addAttributeToSelect('increment_id')
->addAttributeToSelect('created_at')
->addAttributeToSelect('state')
->addAttributeToSelect('grand_total')
->addAttributeToSelect('tax_amount')
->addAttributeToSelect('order_currency_code')
->joinAttribute('billing_firstname', 'order_address/firstname', 'billing_address_id', null, 'left')
->joinAttribute('billing_lastname', 'order_address/lastname', 'billing_address_id', null, 'left')
->joinAttribute('order_increment_id', 'order/increment_id', 'order_id', null, 'left')
->joinAttribute('order_created_at', 'order/created_at', 'order_id', null, 'left');
$this->setCollection($collection);
return parent::_prepareCollection();
}
同样,这是未经测试的,从内存中这是magento 1.3范围内的_prepareCollection,所以它有点旧,但很确定它应该可以工作。