为Magento1.5新增会员注册字段

第一步、新建一个模块,在app/etc/modules/目录下新建文件Shuishui_Customer.xml

<config>
    <modules>
        <Shuishui_Customer>
            <active>true</active>
            <codePool>community</codePool>
        </Shuishui_Customer>
    </modules>
</config>
第二步、新建这个模块的config配置文件,位置在 app/code/community/Shuishui/Customer/etc/config.xml

<?xml version="1.0"?>

<config>
    <modules>
        <Shuishui_Customer>
            <version>0.1.0</version>
        </Shuishui_Customer>
    </modules>
    <global>
    <fieldsets>
        <customer_account>
              <mobile><create>1</create><update>1</update></mobile>
        </customer_account>
    </fieldsets>
        <models>
            <Shuishui_Customer>
                <class>Shuishui_Customer_Model</class>
            </Shuishui_Customer>
        </models>
        <helpers>
            <Shuishui_Customer>
                <class>Shuishui_Customer_Helper</class>
            </Shuishui_Customer>
        </helpers>
        <resources>
            <customerattribute_setup>
                <setup>
                    <module>Shuishui_Customer</module>
                    <class>Shuishui_Customer_Model_Entity_Setup</class>
                </setup>
            </customerattribute_setup>
        </resources>
    </global>
  

 
    
</config>
第三步、新建一个model类,继承自Mage_Customer_Model_Entity_Setup类,类里新添加一个字段,位置在 app/code/community/Shuishui/Customer/Model/Entity/Setup.php

class Fanxiang_Customer_Model_Entity_Setup extends Mage_Customer_Model_Entity_Setup
'created_at' => array(
                        'type'          => 'static',
                        'label'         => 'Created At',
                        'visible'       => false,
                        'required'      => false,
                        'input'         => 'date',
                    ),
                    'mobile' => array(
                        'type'          => 'static',
                        'label'         => 'Mobile',
                        'visible'       => true,
                        'required'      => false,
                        'sort_order'    => 80,
                    ),
                ),
            ),

            'customer_address'=>array(
                'entity_model'  =>'customer/customer_address',
                'table' => 'customer/address_entity',
                'additional_attribute_table' => 'customer/eav_attribute',
                'entity_attribute_collection' => 'customer/address_attribute_collection',

第四步、新增一个数据库安装脚本文件,位置在 app/code/community/Shuishui/Customer/sql/customerattribute_setup/mysql4-install-0.1.0.php

$installer = $this;

$installer->startSetup();

$installer->addAttribute('customer','mobile',array(
      'label' => 'Mobile',
      'visible'=>1,
      'required'=>0,
      'position'=>1,
      'sort_order'=>80,
    
));

$installer->endSetup();

$customerattribute = Mage::getModel('customer/attribute')->loadByCode('customer','mobile');
$forms = array('customer_account_edit','customer_account_create','adminhtml_customer','checkout_register');
$customerattribute->setData('used_in_forms',$forms);
$customerattribute->save();
第五步,在前台注册页面的模板文件中添加一个新的表单项, 位置在 template\customer\form\register.phtml

<li>
                    <label for="mobile" class="required"><em>*</em><?php echo $this->__('mobile') ?></label>
                    <div class="input-box">
                        <input type="text" name="mobile" id="mobile" value="" title="<?php echo $this->__('mobile') ?>" class="input-text  required-entry" />
                    </div>
                </li>
前台显示效果



后台会员管理页面效果



PS:1.4版本同样适用

参见原文:http://mydons.com/how-to-add-custom-fields-to-customer-registration-and-account-page-in-magento-1-5/


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值