Magento Customer Grid - Mask Email address

落花浮王杯 提交于 2019-12-01 11:04:05
Renon Stewart

Write a custom module that extend:

/app/code/core/Mage/Adminhtml/Block/Customer/Grid.php

Read more @ How to get data for an entity (for example customer) from eav_attribute table to be shown in Customer Grid for admin (remove line with sales_order_grid)

Copy '_prepareColumns()' method to your custom module and change

    $this->addColumn('email', array(
        'header'    => Mage::helper('customer')->__('Email'),
        'width'     => '150',
        'index'     => 'email'
        'renderer' = new MageIgniter_MaskEmail_Block_Adminhtml_Renderer_Data()  // added this line
    ));

Read more @ http://www.magentocommerce.com/boards/viewthread/192232/#t239222

Create Class:

 class MageIgniter_MaskEmail_Block_Adminhtml_Renderer_Data extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action
 {
    public function render(Varien_Object $row)
     {
         return $this->_getValue($row);
     }

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

         $search_filter = base64_decode($this->getRequest()->getParam('filter'));
         // print_r($search_filter) : email=rs%40cs.com&customer_since%5Blocale%5D=en_US
         //read more @ http://inchoo.net/ecommerce/magento/what-is-base64-encoding-and-how-can-we-benefit-from-it/

         // check if $search_filter contain email and equal to the search email
         parse_str($search_filter, $query)
         if(isset($query['email'] && $val == $query['email']){  // or array_key_exist()
            return $val;
         }
         else{
             return 'xxxxxxxx';
         }

     } 
 }

This is base off Magento v1.7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!