【问题标题】:How to customize the database value in magento customer grid如何在magento客户网格中自定义数据库值
【发布时间】:2013-02-23 06:39:34
【问题描述】:

我为特殊用途的客户模块创建了新的 magento 网格。

其中有一列 usertype 它的值为 0,1,2。

它将在客户网格页面中显示为 0,1,2。

但如果值是,我需要显示,

 0 -> Inactive
 1 -> Activated
 2 -> Baned

我该怎么做?

这是我在 _prepareColumns() 中的代码 grid.php :

$this->addColumn('usertype', array(
            'header'    => Mage::helper('customer')->__('Usertype'),
            'width'     => '150',
            'index'     => 'usertype'
        ));

如果这在 magento 中是可能的。

【问题讨论】:

  • 有人对此有任何解决方案吗?

标签: magento magento-1.7


【解决方案1】:

如果你的贪婪实现Mage_Adminhtml_Block_Widget_Grid我建议你修改 你addColumn打电话给

$this->addColumn('usertype',
        array(
            'header'=> Mage::helper('customer')->__('Usertype'),
            'width' => '150px',
            'index' => 'usertype',
            'type'  => 'options',
            'options' => $values
        ));

$values 应格式化为

array( 'value_id' => 'value_label')

现在您已经使用值创建了下拉列表。 然后更新_prepareCollection() 函数并将属性值添加到客户网格集合 $collection->joinAttribute('usertype', 'customer/usertype', 'entity_id', null, 'left');

【讨论】:

    【解决方案2】:

    我从this得到了解决方案

    通过使用 rendere 将有助于将 vlaues 加载到每一行。

    【讨论】:

    • 这为您指明了正确的方向,但这确实是一个答案。您至少应该综合这里的重要步骤。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-10
    相关资源
    最近更新 更多