步骤 I. 加一个occupation/title字段到用户注册页,差不多在register.html的54行,在email下方加一个Occupation显示代码
<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->
代码:
<li>
<div class="input-box">
<label for="email_address"><?php echo $this->__('Email
Address') ?> <span
class="required">*</span></label><br/>
<input type="text" name="email"
id="email_address" value="<?php echo
$this->htmlEscape($this->getFormData()->getEmail()) ?>"
title="<?php echo $this->__('Email Address') ?>" class="validate-email
required-entry input-text" />
</div>
<div class="input-box">
<label for="occupation"><?php echo
$this->__('Occupation/Title') ?></label><br/>
<input type="text" name="occupation"
id="occupation" value="<?php echo $this->htmlEscape($this->getFormData()->getOccupation())
?>" title="<?php echo $this->__('Occupation') ?>"
class="input-text" />
</div>
</li>
这是,如果进入用户注册页, 就会看到新增的字段。
步骤 2 同样在edit.phtml中,加入Occupation显示块
代码:
<li>
<div class="input-box">
<label for="email"><?php echo $this->__('Email Address')
?> <span class="required">*</span></label><br
/>
<input type="text" name="email" id="email"
value="<?php echo
$this->htmlEscape($this->getCustomer()->getEmail()) ?>"
title="<?php echo $this->__('Email Address') ?>" class="required-entry
validate-email input-text" />
</div>
</li>
<li>
<div class="input-box">
<label for="occupation"><?php echo
$this->__('Occupation') ?> </label><br/>
<input type="text" name="occupation"
id="occupation" value="<?php echo
$this->htmlEscape($this->getCustomer()->getOccupation()) ?>"
title="<?php echo $this->__('Occupation') ?>"
class="input-text" />
</div>
</li>
步骤 3, 打开Model/Entity/Setup.php差不多在93行,email的下方,加入occupation的相关代码:
代码:
'email' => array(
'type' => 'static',
'label' => 'Email',
'class' => 'validate-email',
'sort_order' => 60,
),
'occupation' => array(
'label' => 'Occupation',
'required' => false,
'sort_order' => 65,
),
步骤4: 现在,代码就基本写好了
, 但是我们仍然需要执行一个数据库操作将occupation这个属性加入到eav_attribute表,把下面的代码块:
代码:
<?php
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$AttrCode = 'occupation';
$settings = array (
'position' => 1,
'is_required'=> 0
);
$setup->addAttribute('1', $AttrCode, $settings);
?>
放到合适的文件里执行一次。我建议把它放到register.html文件的顶部,然后重新访问register.html.查看数据库eav_attribute表就能看到新增的条目。然后把上面的代码从register.phtml中移除。
步骤 5:编辑app/code/core/Mage/Customer/etc/config.xml 的<fieldsets>标签下声明该字段如何处理插入和贵呢更新
代码:
<fieldsets>
<customer_account>
.....
<occupation><create>1</create><update>1</update></occupation>
</customer_account>
</fieldsets>
步骤 6: 最后需要在表customer_form_attribute表增加记录,将新增字段与customer的前台显示表格关联:
form code attribute_id
adminhtml_checkout 264
adminhtml_customer 264
checkout_register 264
customer_account_create 264
customer_account_edit 264
Attribute_id 是指该属性在eav_attribute表的attribute_id。
分享到:
相关推荐
Magento如何给新注册用户一个优惠券代码
magento中文用户指南
magento用户使用手册
magento用户中文操作手册,学习magento后台管理
Magento用户手册
Magento是一款新的、专业的、开放源代码的电子商务解决方案,它提供前所未有的灵活性和可控制性。有了Magento,在你开展电子商务业务的时候就不会觉得很困难了。Magento 的特色1 容易整合Magento 让整合第三方厂商...
对magento的各个功能进行了介绍。中文版。
magento用户中文操作手册,学习magento后台管理
Magento2的客户和地址表单字段经理 快速轻松地从管理员订单创建和客户帐户中删除不需要的表单字段...field-manager手动地下载扩展解压缩文件创建一个文件夹{Magento 2 root} / app / code / MagePal / FormFieldManage
magento中文用户指南,描述magento开发和配置过程
magento判断用户是否登录和怎么获取登录者名称:
Magento 系统抽象出来,用一个配置文件来描述。这里的“配置文件”并不是一 个物理上存在的文件,而是 Magento 根据当前的系统状态动态生成的一段 XML 。 大多数的 PHP 开发者并不习惯于这样抽象层,因为它增加的...
magento数据结构分析 magento数据字典
magento中文用户手册,详细介绍Magento各项功能及开发
Magento是一款新的、专业的、开放源代码的电子商务解决方案,它提供前所未有的灵活性和可控制性。有了Magento,在你开展电子商务业务的时候就不会觉得很困难了。 Magento 的特色 1 容易整合 Magento 让整合第三方...
外贸网站开源程序 magento 中文用户手册
magento 英文用户手册,magento2009年版。TheOfficialMagentoUserGuide.pdf 共209页
magento中国地址编辑插件,针对中国添加省份。添加省市区三级联动即将推出,敬请期待。
magik shoes magento 模板, magento 1.7 模板
快速在服务器上复制为另一个站,版本用的是magento,php语言