magento添加客户自定义字段
来源:互联网 发布:文明5 for mac 汉化 编辑:程序博客网 时间:2024/05/17 00:10
INSERT INTO `eav_attribute` (`attribute_id` ,`entity_type_id` ,`attribute_code` ,`attribute_model` ,`backend_model` ,`backend_type` ,`backend_table` ,`frontend_model` ,`frontend_input` ,`frontend_label` ,`frontend_class` ,`source_model` ,`is_required` ,`is_user_defined` ,`default_value` ,`is_unique` ,`note`) VALUES (NULL , '1', 'customertype', NULL , '' , 'int', '' , '' , 'select', 'Customer Type', '' , 'eav/entity_attribute_source_table', '1', '0', '', '0', '');运行上面语句后得到attribute_id再运行下面语句(例如attribute_id为121,120为sort_order)INSERT INTO `eav_entity_attribute` (`entity_attribute_id` ,`entity_type_id` ,`attribute_set_id` ,`attribute_group_id` ,`attribute_id` ,`sort_order`)VALUES (NULL , '1', '1', '1', '121', '120');INSERT INTO `customer_eav_attribute` (`attribute_id` ,`is_visible` ,`input_filter` ,`multiline_count` ,`validate_rules` ,`is_system` ,`sort_order` ,`data_model`)VALUES ('121', '1', '' , '1', '' , '0', '120', NULL);INSERT INTO `customer_form_attribute` (`form_code` ,`attribute_id`)VALUES ('adminhtml_customer', '121'), ('checkout_register', '121'), ('customer_account_create', '121'), ('customer_account_edit', '121');下面为添加的选项INSERT INTO `eav_attribute_option` (`option_id`, `attribute_id`, `sort_order`) VALUES(NULL, 121, 0),(NULL, 121, 1),(NULL, 121, 2),(NULL, 121, 3);下面5,6,7,8为 eav_attribute_option 的 option_idINSERT INTO `eav_attribute_option_value` (`value_id`, `option_id`, `store_id`, `value`) VALUES(NULL, 5, 0, 'Wholesaler'),(NULL, 6, 0, 'Retailers'),(NULL, 7, 0, 'Agents'),(NULL, 8, 0, 'Individual customers');
在注册页面(/customer/form/register.phtml)添加:
<li> <?php $attribute = Mage::getModel('eav/config')->getAttribute('customer','customertype'); ?> <div class="input-box" style="float:left; clear:none; width:275px;"><label for="customertype"><?php echo $this->__('Customer Type') ?><?php if($attribute->getIsRequired() == true){?> <span class="<?php if($attribute->getIsRequired() == true){?>required<?php } ?>">*</span><?php } ?></label><br /> <select name="customertype" id="customertype" class="<?php if($attribute->getIsRequired() == true){?>required-entry<?php } ?>"> <?php $options = $attribute->getSource()->getAllOptions(); foreach($options as $option){ ?> <option value='<?php echo $option['value']?>' <?php if($this->getFormData()->getCustomertype() == $option['value']){ echo 'selected="selected"';}?>><?php echo $this->__($option['label'])?></option> <?php } ?> </select> </div></li>在编辑页面(/customer/form/edit.phtml)添加:
<li> <?php $attribute = Mage::getModel('eav/config')->getAttribute('customer','customertype'); ?> <div class="input-box" style="float:left; clear:none; width:275px;"><label for="customertype"><?php echo $this->__('Customer Type') ?><?php if($attribute->getIsRequired() == true){?> <span class="<?php if($attribute->getIsRequired() == true){?>required<?php } ?>">*</span><?php } ?></label><br /> <select name="customertype" id="customertype" class="<?php if($attribute->getIsRequired() == true){?>required-entry<?php } ?>"> <?php $options = $attribute->getSource()->getAllOptions(); foreach($options as $option){ ?> <option value='<?php echo $option['value']?>' <?php if($this->getCustomer()->getCustomertype() == $option['value']){ echo 'selected="selected"';}?>><?php echo $this->__($option['label'])?></option> <?php } ?> </select> </div></li>
- magento添加客户自定义字段
- Magento - Contact Form 添加自定义字段
- magento 添加会员注册字段
- magento添加添加自定义属性
- Magento后台表单字段添加备注
- magento product 添加新的字段
- magento如何添加自定义插件(模块
- Magento中目录添加自定义属性代码
- Magento 目录添加自定义属性例子
- dedecms栏目添加字段--栏目自定义字段
- 添加jira的自定义字段
- Magento Grid collection联表查询添加字段
- Magento后台订单列表页,增加SKU、Qty、客户邮箱字段
- 动态自定义字段属性--Magento的EAV模型
- magento -- 如何为商品分类(category)添加自定义属性
- magento -- 如何为商品分类(category)添加自定义属性
- Magento 在 Onepage Checkout 页面添加自定义 Fields
- dede首页添加自定义字段详细介绍
- 二分查找那些事儿(3)
- OA
- 利用Word“自动更正”功能快速输入文字[办公软件]
- Android Rss阅读器
- 【xinfanqie】新手教程:如何让Win 7更新完后不自动重启
- magento添加客户自定义字段
- C#基础概念二十五问
- 浅谈ClassLoader
- Write an Efficient C Program to Reverse Bits of a Number
- Android ViewPager使用详解
- Extjs Tab closeTab 显示中文
- Loadrunner的使用
- textView 添加超链接
- c++ 如何获取系统时间??