关于magento用户姓名中文化

  因magento用的是西方的姓名规则,即前名firstname,后姓lastname,与我们国内姓名规则相反;这里通过修改后姓lastname为非必填,并隐藏,将前名firstname作为姓名整体使用,用这个方法来解决magento二次开发的中文姓名颠倒问题。

  一、修改数据库字段属性

  UPDATE `eav_attribute` SET `is_required` = '0' WHERE `eav_attribute`.`attribute_id` =22;

  UPDATE `eav_attribute` SET `is_required` = '0' WHERE `eav_attribute`.`attribute_id` =7;

  UPDATE `customer_eav_attribute` SET `validate_rules` = 'a:2:{s:15:"max_text_length";i:255;s:15:"min_text_length";i:0;}' WHERE `customer_eav_attribute`.`attribute_id` =7;

  UPDATE `customer_eav_attribute` SET `validate_rules` = 'a:2:{s:15:"max_text_length";i:255;s:15:"min_text_length";i:0;}' WHERE `customer_eav_attribute`.`attribute_id` =22;

  执行以上两条sql,把字段属性先设置为非必填。

  注意:以上代码非普遍适用,最好打开数据库手工修改!

  二、去掉验证代码  修改文件app/code/core/Mage/Customer/Model/Address/Abstract.php,找到这个并注释掉:

  if (!Zend_Validate::is($this->getLastname(), 'NotEmpty')) {

  $this->addError(Mage::helper('customer')->__('Please enter the last name.'));

  }

  修改文件app/code/core/Mage/Customer/Model/Customer.php,找到这个并注释掉:

  if (!Zend_Validate::is( trim($this->getLastname()) , 'NotEmpty')) {

  $errors[] = Mage::helper('customer')->__('The last name cannot be empty.');

  }

  三、新问题  将lastname修改为非必填后,当lastname输入为空值时,网站后台的客户管理列表中不显示用户名,解决方法如下:

  修改文件:/app/code/core/Mage/Adminhtml/Block/Customer/Grid.php,将:

  /*$this->addColumn('firstname', array(

  'header' => Mage::helper('customer')->__('First Name'),

  'index' => 'firstname'

  ));

  $this->addColumn('lastname', array(

  'header' => Mage::helper('customer')->__('Last Name'),

  'index' => 'lastname'

  ));*/

  $this->addColumn('name', array(

  'header' => Mage::helper('customer')->__('Name'),

  'index' => 'name'

  ));

  改为:

  $this->addColumn('firstname', array(

  'header' => Mage::helper('customer')->__('First Name'),

  'index' => 'firstname'

  ));

  /*$this->addColumn('lastname', array(

  'header' => Mage::helper('customer')->__('Last Name'),

  'index' => 'lastname'

  ));

  $this->addColumn('name', array(

  'header' => Mage::helper('customer')->__('Name'),

  'index' => 'name'

  ));*/

  以上更改启用了firstname栏目,禁用了lastname和name栏目。

  四、magento前端隐藏后姓lastname(可选)

  使用css将mangeto前端的lastname输入栏目隐藏掉,在style.css后加入:

  div.name-lastname{display:none;}/*注:magento modern theme适用。*/

  五、完成。

转载于:https://my.oschina.net/u/3840660/blog/3043143

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值