zoukankan      html  css  js  c++  java
  • 为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();

    第五步,在前台注册页面的模板文件中添加一个新的表单项,位置在templatecustomerform egister.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/

  • 相关阅读:
    [AT2064] [agc005_f] Many Easy Problems
    [AT2304] [agc010_c] Cleaning
    [AT2172] [agc007_e] Shik and Travel
    [AT2148] [arc063_c] Integers on a Tree
    [AT2363] [agc012_c] Tautonym Puzzle
    未能从程序集“netstandard, Version=2.0.0.0......”中加载类型“...”。
    Android Studio设置国内镜像代理
    新建一个浏览器APP
    Android Studio在Make Project时下载Grandle特别慢
    用JS添加和删除class类名
  • 原文地址:https://www.cnblogs.com/xingmeng/p/4803377.html
Copyright © 2011-2022 走看看