我創建了custom module to add Land Phone field in registration page
。該form display the field but in database the Land Phone number is not inserted
。但在eav_attribute table
中添加了landphone屬性。唯一的問題是Land Phone的價值並未插入到客戶表中。我遵循本教程:http://www.fontis.com.au/blog/magento/know-more-about-your-customers-adding-custom-signup-attributes使用定製模塊進行註冊時,數據未插入到magento數據庫中
我會給你詳細的代碼,我做了什麼。
我的模塊名稱是TCreg_Customer
應用程序的/ etc /模塊/ TCreg_Customer.xml
<?xml version="1.0"?>
<config>
<modules>
<TCreg_Customer>
<codePool>local</codePool>
<active>true</active>
</TCreg_Customer>
</modules>
</config>
應用程序/代碼/本地/ TCreg /客戶的/ etc/config.xml中
I copy app/code/core/Mage/Customer/etc/config.xml
file and make 2 changes
<modules>
<TCreg_Customer>
<version>1.0.0</version>
</TCreg_Customer>
</modules>
,並添加
<landphone><create>1</create><update>1</update></landphone>
內<customer_account>
標籤
應用程序/代碼/本地/ TCreg /客戶/型號/實體/ Setup.php
<?php
class TCreg_Customer_Model_Entity_Setup extends Mage_Customer_Model_Entity_Setup
{
public function getDefaultEntities(){
return array(
'landphone'=>array(
'type'=> 'varchar',
'label'=> 'Land Phone',
'visiable' => true,
'sort_order' => 80,
)
);
}
}
?>
土地電話場設置在register.phtml
位於app/design/frontend/mytheme/template/persistent/customer/form/registe r.phtml
<!--landphone field begin-->
<div class="field">
<label for="landphone"><?php echo $this->__('Land Phone') ?></label>
<div class="input-box">
<input type="text" name="landphone" id="landphone" value="<?php echo $this->escapeHtml($this->getFormData()->getLandphone()) ?>" title="<?php echo $this->__('Land Phone') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('landphone') ?>" />
</div>
</div>
<!--landphone field end-->
應用程序/設計/前端/ mytheme的/模板/永久/客戶/地址/ edit.phtml需要添加
<!--Landphone field begin-->
<div class="field">
<label for="landphone"><?php echo $this->__('Land Phone') ?></label>
<div class="input-box">
<input type="text" name="landphone" value="<?php echo $this->htmlEscape($this->getAddress()->getLandphone()) ?>" title="<?php echo $this->__('Land Phone') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('landphone') ?>" id="landphone" />
</div>
</div>
<!--Landphone field end-->
新的屬性(土地電話)到Magento數據庫。所以我加了這些代碼位register.phtml
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->addAttribute('customer', 'landphone', array(
'label' => 'Land Phone',
'type' => 'varchar',
'input' => 'text',
'visible' => true,
'position' => 1,
));
我認爲唯一的問題是客戶表中沒有插入手機土地的價值。但我找不到解決方案。所以請幫助我..我該如何解決這個問題?任何幫助真的是可觀..
我Magento的版本是1.9.1.0
看一看以下職位爲同一目的:HTTP://phpmagento.blogspot.in/2012/02/custom-field-in-customer-registration。 html 希望你會得到一些想法以另一種方式做到這一點...不要忘了將核心文件複製到本地代碼池文件夾 – 2015-03-19 11:55:44
@VinodKumar,它是什麼? '不要忘記將核心文件複製到本地代碼池文件夾中' – next2u 2015-03-20 04:39:11
我提到你的鏈接直接顯示核心文件中的所有代碼修改...所以我建議你複製所有文件將編輯,進入本地/法師目錄... – 2015-03-20 05:18:00