0

注文と請求書 (バックエンド) のグリッドに支払いオプションを表示しようとしています。

コアファイルをコピーしました

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時間グーグルで検索しました。どこを見ればいいのか教えてください。

ありがとうございました。

4

1 に答える 1

0

私があなたを正しく理解しているなら、あなたはそれのラベルで代用メソッドIDを必要とします。_prepareColumns()次の方法でグリッドメソッドでそれを行う必要があります。

    $this->addColumn('method', array(
        ...
        'type'  => 'options',
        'options' => array('method_id1' => 'label1', 'method_id2' => 'label2', ...),
    ));
于 2012-01-24T10:41:18.323 に答える