為Magento1.5新增會員註冊欄位(轉)

來源:互聯網
上載者:User

標籤:

第一步、建立一個模組,在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/

 

為Magento1.5新增會員註冊欄位(轉)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.