注文と請求書 (バックエンド) のグリッドに支払いオプションを表示しようとしています。
コアファイルをコピーしました
app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php
app/code/core/Mage/Adminhtml/Block/Sales/Invoice/Grid.php
ローカル フォルダーに移動し、関数 _prepareCollection() および _prepareColumns() を編集します。列の準備は簡単です。問題は収集にあります。
私の変更:
ファイル: app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php
protected function _prepareCollection(){
$collection = Mage::getResourceModel($this->_getCollectionClass());
$collection->getSelect()->joinLeft('sales_flat_order', 'main_table.entity_id = sales_flat_order.entity_id',array('total_qty_ordered', 'shipping_description'));
$collection->getSelect()->joinLeft('sales_flat_order_payment', 'sales_flat_order_payment.parent_id = main_table.entity_id',array('method'));
// this is custom function that retrieves an array with payment option and its label
$metode = $this->getActivePaymentMethods();
// we get labels of payment options
foreach ($collection as $afn) {
foreach ($metode as $method) {
if ($method['value'] == $afn['method']) {
$afn->setData('method', $method['label']);
}
}
}
$this->setCollection($collection);
return parent::_prepareCollection();
}
このコードは、実際に行うべきことを行います。この注文で使用された支払いと配送オプションを取得します。しかし、コレクションに「メソッド」を追加すると、ページネーションと順序が壊れます。
すべての注文が 1 ページに表示され、注文は機能しません。請求書も同様です。
私は今、何の運もなく1時間グーグルで検索しました。どこを見ればいいのか教えてください。
ありがとうございました。