0

我有一个模块,可将付款方式列添加到“销售”>“订单”网格。

$this->addColumn('method', array(
                'header' => Mage::helper('sales')->__('Payment<br />Method'),
                'index' => 'method',
                'renderer'  => 'Artizara_Ordergridadditions_Block_Catalog_Product_Renderer_Payment',
                'filter_index' => 'sfop.method', // refers to a declaration above
                type'  => 'options',
                'options' => array(0=>'Option 1',1=>'Option2'), // how would I get the keys to match to the renderer options???
        ));

渲染器代码(下):

public function render(Varien_Object $row) {
    $value =  $row->getData($this->getColumn()->getIndex());

    switch ($value) {
    case 'authorizenet':
        $value = 'Credit Card (Authorize.net)';
        $span = '';
        break;
    case 'paypal_express':
        $value = 'Paypal Express';
        $span = '';
        break;
    case 'checkmo':
        $value = 'Check/Money Order';
        $span = '';
        break;
    case 'free':
        $value = 'No Payment Required';
        $span = '';
        break;
    default:
        $value = 'Unknow Payment Method';
        $span = 'style="color:red;"';
    }

    return '<span ' . $span . '>' . $value . '</span>';
}

只是希望能够使用渲染器选项预先填充下拉列表,以便在网格中进行过滤。

注意:如果我添加文本字段方法进行过滤,您必须输入数据库中的原始密钥(例如 - checkmo、paypal_express、authorizenet 等)。

我希望能够在下拉列表中显示每个渲染器值...(如何)?

编辑 7/20/12

我尝试了以下两种方法,但还没有工作......

'options' => array(
                    array('value' => 'authorizenet', 'label' => 'Credit Card (Authorize.net)'),
                    array('value' => 'paypal_express', 'label' => 'Paypal Express'),
                    array('value' => 'checkmo', 'label' => 'Check/Money Order'),
                    array('value' => 'free', 'label' => 'No Payment Required'),
                ),

只是给我一个下拉列表,其中包含 4 个选项,如下所示:

Array
Array
Array
Array

我也试过这样:

'options' => array(
                    array => ('value' => 'authorizenet', 'label' => 'Credit Card (Authorize.net)'),
                    array => ('value' => 'paypal_express', 'label' => 'Paypal Express'),
                    array => ('value' => 'checkmo', 'label' => 'Check/Money Order'),
                    array => ('value' => 'free', 'label' => 'No Payment Required'),
                ),

但我收到一个错误:

Parse error: syntax error, unexpected T_DOUBLE_ARROW, expecting '('

4

3 回答 3

1

试试这个:

        'type'      => 'options',
        'options'       => Mage::helper('payment')->getPaymentMethodList(true),
        'option_groups' => Mage::helper('payment')->getPaymentMethodList(true, true, true),
于 2013-08-05T19:19:33.537 回答
0

将选项哈希与您在渲染器中使用的值一起使用:

'options' => array(
   'authorizenet' => 'Credit Card (Authorize.net)',
   [..]
)

附带说明一下,您可能对Enhanced Admin Grids我开发的扩展(Magento Connect 上的页面)感兴趣, github上提供的最新版本带来了一个自定义列系统,允许添加新列而无需重写并且具有相当多的可能性。
作为基础,它带有用于订单网格的付款方式列。

于 2012-07-20T07:14:49.963 回答
0

访问 http://www.magentocommerce.com/boards/viewthread/207929/

你可能会得到你的问题的答案。

于 2013-02-04T12:19:42.137 回答