English 中文(简体)
如何增加一栏,例如Magento s Admin Order Grid的客户团体
原标题:How to add a column for example customer group id in Magento s Admin Order Grid

我想在命令中增加一个专栏。 假设客户群Id。

I app/etc/modules/My Project_ Adminhtml

<?xml version="1.0"?>

<config>
    <modules>
        <MyProject_Adminhtml>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Mage_Sales />
            </depends>
        </MyProject_Adminhtml>
    </modules>
</config>

I app/code/ local/Myproject/Adminhtml/etc/config.xml looks:

<?xml version="1.0"?>
<config>
    <modules>
        <MyProject_Adminhtml>
            <version>1.0.0</version>
        </MyProject_Adminhtml>    
    </modules>

    <global>
          <blocks>
            <adminhtml>
                <rewrite>
                    <sales_order_grid>MyProject_Adminhtml_Block_Sales_Order_Grid</sales_order_grid>
                </rewrite>
            </adminhtml>
        </blocks>

      </global>

  </config>

而且,见附录/编码/当地/男性项目/Adminhtml/Block/Sales/Order/Grid.php。 页: 1

class MyProject_Adminhtml_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid
{

    protected function _prepareColumns()
    {
        .... unchanged code from Mage_Adminhtml_Block_Sales_Order_Grid::_prepareColumns ...

        $this->addColumn( customer_group_id , array(
             header  => Mage::helper( sales )->__( Customer Group Id ),
             index  =>  customer_group_id ,
             type   =>  text ,
        ));

         .... unchanged code from Mage_Adminhtml_Block_Sales_Order_Grid::_prepareColumns ...
    }
}

是否有人失踪,因为我看不到《命令》中的任何内容。 我正在使用Magento 1.4.1.1。

On Anda B 评论一写道:

var_dump($this->getLayout()->createBlock( MyProject_Adminhtml_Block_Sales_Order_Grid ));

页: 1

之后,我选择了新命令和Cancel的顺序,以了解执行var的结果。

/var/www/magento/var/report/72990635: line 10: syntax error near unexpected token `}  /var/www/magento/var/report/72990635: line 10: `#9 {main}";s:3:"url";s:80:"/index.php/admin/sales_order_create/cancel/key/0624033594dd63d9e145fc538f4c6bbb/";s:11:"script_name";s:10:"/index.php";s:4:"skin";s:5:"admin";} 
最佳回答

In modules/etc you have Atzen_Adminhtml but your project is MyProject_Adminhtml. Except this problem the code should work: even if you don t have the customer_group_id in sales table, the new column should appear in the grid.

问题回答

你们几乎在那里。

由于核心不存在,你需要为全球资源信息数据库建立一个使者。

首先,在您的增列中加入:

$this->addColumn( customer_group_id , array(
         header  => Mage::helper( sales )->__( Customer Group Id ),
         index  =>  customer_group_id ,
         type   =>  text ,
         renderer  =>  adminhtml/widget_grid_column_renderer_customergroup ,
    ));

现在,你们需要创建目录/申请/编码/地方/My Project/Adminhtml/Widget/Grid/Column/Renderer,因为这很可能没有。

现在建立一个客户小组。 网址:www.un.org

class MyProject_Adminhtml_Block_Widget_Grid_Column_Renderer_Customergroup extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract

页: 1

 private static $_customergroups = array();

 public static function getCustomerGroupsArray() 页: 1
     if(count(self::$_customergroups) == 0) 页: 1
         $customer_group = Mage::getModel( customer/group );
         $customer_groups = $customer_group->getCollection()->toOptionHash();
         self::$_customergroups = $customer_groups;
     }
     return self::$_customergroups;
 }

public function render(Varien_Object $row)页: 1
       $value = $this->_getValue($row);
       $customer_groups = self::getCustomerGroupsArray();
       return isset($customer_groups[$value]) ? $customer_groups[$value] : false;
    }
}

最后,你们将需要在我的项目中增加这一内容。 为此:

<widget_grid_column_renderer_customergroup>Myproject_Adminhtml_Block_Widget_Grid_Column_Renderer_Customergroup</widget_grid_column_renderer_customergroup>

权利与你的其他rew子。

在您的问候之后,您应当请您在您的问候之后再接过你。 销售订单中的集团标签。

PS。

如果你想在销售订单网顶上添加一个过滤器,以便与这一栏相配合,在售货机之后添加“Column”一词。 (顺序实际上不重要)

<代码>备选方案 => ReadyStore_Adminhtml_Block_Widget_Grid_Column_Renderer_Customergroup:getCustomergroups Array(

将案文改为备选案文

Cheers Roy





相关问题
Automatic Sales Tax Tables

A client needs the ability for their shopping cart to automatically retrieve and keep up to date sales tax tables for at least the US, and preferably all countries with which the US has tax treaties. ...

ecommerce stock management with external payment gateway

this question is similar to this one but with a twist (so the answer accepted for the older question is not valid in the following scenario) i have a site for selling tickets (PHP/MYSQL). Suppose i ...

are automated recurring billings really automated?

"roll your own recurring billing in your rails app with a cron job, a date field for when they are paid through, and amount each person is paying" I just saw this entry here in SO and wonder if ...

ECommerce solution in php and ror [closed]

I m a developer but I never used php nor ruby on rails. I would like to create a small e-commerce website. I found out 2 solutions that seems very good, Prestahop and Spree. Which one would you ...

How to link username in site to PayPal information email?

It s not a problem but i don t know how to do this; let s say that I have a sign up form with some fields: username, password, email, as you know the user clicks on the BUY BUTTON and pay s up. Well, ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

热门标签