2012-01-23 9 views
0

私は注文と請求書のグリッド(バックエンド)に支払いオプションを表示しようとしています。Magento - 参加後のフィルタ注文/請求書の収集とカスタムアクション

私はコアファイルのローカルフォルダへ

app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php 
app/code/core/Mage/Adminhtml/Block/Sales/Invoice/Grid.php 

、その後、編集機能の_prepareCollection()と_prepareColumnsをコピーしました()。列を準備することは簡単ではなく、問題は収集中です。

私の変更:

ファイル:アプリ/コード/コア/メイジ/ Adminhtml /ブロック/販売/受注/ 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時間グーグルで行きました。あなたは私に見える方向を教えてもらえますか?

ありがとうございます。

+0

私はすでにそれを持っています。適切な値を表示します。 問題は、ページネーションが壊れていることです。 –

+0

これは正しいようです。私はそれを理解できませんでした。ありがとう! –

答えて

0

私はあなたのことをよく理解していれば、代わりにそのメソッドのidを代用する必要があります。あなたのグリッドでそれを次の方法で

の方法で行うべきです:
$this->addColumn('method', array(
     ... 
     'type' => 'options', 
     'options' => array('method_id1' => 'label1', 'method_id2' => 'label2', ...), 
    )); 
+0

あなたは私の友人であり、救命救助者です! @Cagsはすでにそれを言ったように、私は理解していませんでした。あなたは彼が話していたことを示しました。ありがとうございました。 –

関連する問題