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() を動作させることさえできません。
その問題を乗り越えたら、行っている変更が正しいものであることを確認する必要があります。私は顧客の会社名を取得しようとしているだけです。今回追加したのは以下の2点です。
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を使用しています