Magento,使用XML标记方法扩展订单网格,选择选项 [英] Magento, Extending Order Grid using XML markup method, select options issue

查看:55
本文介绍了Magento,使用XML标记方法扩展订单网格,选择选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一些有关如何在Magento订单网格中填充选择选项标题的示例.以下是创建新列以呈现数据并在列标题中输出选择菜单.问题是未在选择菜单中创建选项.

I am looking for some an example of how to populate a select option header in Magento order grid. The following is creating the new column rendering the data and outputting a select menu in the column header. The issue is the options are not being created in the select menu.

<layout>
    <!-- main layout definition that adds the column -->
    <add_order_grid_column_handle>
        <reference name="sales_order.grid">
            <action method="addColumnAfter">
                <columnId>customer_country_id</columnId>
                <arguments module="ordermanager" translate="header">
                    <header>Shipping Country</header>
                    <index>customer_country_id</index>
                    <type>options</type>
                    <sortable>true</sortable>
                    <options>Flipmedia_AddShippingCountryColumn_Adminhtml_Block_Widget_Grid_Column_Renderer_Country</options>
                    <renderer>Flipmedia_AddShippingCountryColumn_Adminhtml_Block_Widget_Grid_Column_Renderer_Country</renderer>
                </arguments>
                <after>status</after>
            </action>
        </reference>
    </add_order_grid_column_handle>

    <!-- order grid action -->
    <adminhtml_sales_order_grid>
        <!-- apply the layout handle defined above -->
        <update handle="add_order_grid_column_handle" />
    </adminhtml_sales_order_grid>

    <!-- order grid view action -->
    <adminhtml_sales_order_index>
        <!-- apply the layout handle defined above -->
        <update handle="add_order_grid_column_handle" />
    </adminhtml_sales_order_index>
</layout>



class Flipmedia_AddShippingCountryColumn_Adminhtml_Block_Widget_Grid_Column_Renderer_Country extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {

    private static $_countryList = array();

    public function options(Varien_Object $row) {
         if (count(self::$_countryList) == 0) {          
            $countries =        Mage::getResourceModel('directory/country_collection')
                                    ->loadData()
                                    ->toOptionArray(false);
            foreach ($countries as $country) {
                self::$_countryList[$country['value']] = $country['label'];
            }
         }

         return self::$_countryList;
     }

    public function render(Varien_Object $row){
           $value = $this->_getValue($row);        
           $_countryList = $this->options();           
           return isset($_countryList[$value]) ? $_countryList[$value] : false;
        }
}

推荐答案

我相信问题出在您的<options>元素上,如果您通过重写重写销售订单网格,则必须为选项指定一个静态函数.我四处看看,看来您需要更改调用此方法的方式.

I believe the issue is with your <options> element, if you override the sales order grid by rewriting it, you have to specify a static function for the options. I've had a look around and it looks like you need to change the way you invoke this.

您可以尝试使用

<filter>Flipmedia_AddShippingCountryColumn_Adminhtml_Block_Widget_Grid_Column_Filter_Country</filter>

请注意新类,它应该像这样扩展Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Select ...签出

Note the new class, it should extend Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Select like this...check out the magento svn as a reference.

class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Grid_Filter_Inventory extends Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Select
{

    protected function _getOptions()
    {
        // return an array of options
        return array(
                array(
                'value' =>  '',
                'label' =>  ''
        ));
    }
}

这篇关于Magento,使用XML标记方法扩展订单网格,选择选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆