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();
}

这段代码实际上做了应该做的事情。它检索用于此订单的付款和运输选项。但是之后,将“方法”添加到集合中会破坏分页和排序。

它在一页上显示所有订单,并且没有订单。发票也是如此。

我已经用谷歌搜索了一个小时,没有任何运气。你能给我一些方向吗?

谢谢你。

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 回答