Adding Field to Admin
First we need to create the address attribute. There are two ways to do this one is through your module sql file or you can do it through directly through sql query.
First we will see it through the module.
In your module’s config.xml file, add this in the resource tag.
<global> <helpers> <myaddress> <class>Bysoft_Myaddress_Helper</class> </myaddress> </helpers> <resources> <myaddress_setup> <setup> <module>Bysoft_Myaddress</module> <class>Mage_Customer_Model_Entity_Setup</class> <!-- This is the important thing--> </setup> <connection> <use>core_setup</use> </connection> </myaddress_setup> <myaddress_write> <connection> <use>core_write</use> </connection> </myaddress_write> <myaddress_read> <connection> <use>core_read</use> </connection> </myaddress_read> </resources>
The important thing is to have your module’s setup class pointed to Mage_Customer_Model_Entity_Setup. Next in the module’s mysql-install file we will put in the code
<?php $installer = $this; $installer->startSetup(); $this->addAttribute('customer_address', 'buyer_mobile', array( 'type' => 'varchar', 'input' => 'text', 'label' => 'Buyer Mobile', 'global' => 1, 'visible' => 1, 'required' => 0, 'user_defined' => 1, 'visible_on_front' => 1 )); Mage::getSingleton('eav/config') ->getAttribute('customer_address', 'buyer_mobile') ->setData('used_in_forms', array('customer_register_address','customer_address_edit','adminhtml_customer_address')) ->save(); $installer->endSetup();
This will add the relevant database entries. If you want to do it directly i.e through database or phpmyadmin. Then you need to do the below.
eav_attribute table
insert a row in this table with values entity_type_id = 2, attribute_code = govt_id, backend_type = varchar, fontend_input = text, fontend_label = Govt ID No#, is_user_defined = 1, is_required = 1, default = NULL.
eav_entity_attribute table
insert a row in this table with values entity_type_id = 2,attribute_set_id =2, attribute_group_id = 2, attribute_id = (The attribute_id or the primary key of the row inserted in the eav_attribute table)
customer_eav_attribute table
insert a row in this table with values attribute_id = (The attribute_id or the primary key of the row inserted in the eav_attribute table), is_visible = 1 rest all column will take default values
customer_form_attribute table
1. insert row in this table with values form_code = adminhtml_customer_address and attribute_id = (The attribute_id or the primary key of the row inserted in the eav_attribute table). This required for the attribute to show up in the admin
2. insert row in this table with values form_code = customer_address_edit and attribute_id = (The attribute_id or the primary key of the row inserted in the eav_attribute table). This required for the attribute to get saved in edit address form and checkout page
3. insert row in this table with values form_code = customer_register_address and attribute_id = (The attribute_id or the primary key of the row inserted in the eav_attribute table). This is required to save the attribute in the create account page
After doing this step, you should be able to do see your new address attribute in the admin.
Address Format Next we need to change the address display format, this format is used everywhere in magento where ever address is displayed. To change the format, go to System -> Configuration -> Customer Configuration -> Address Template There you will see 5 options, we need to change all. Text Add {{depend buyer_mobile}}Buyer Mobile# {{var buyer_mobile}}{{/depend}} where ever you want it. {{depend}} basically checks, if buyer_mobile is not empty. Text One line Add {{depend buyer_mobile}}Buyer Mobile# {{var buyer_mobile}}{{/depend}} where ever you want it. This format shows up in the checkout page shipping,billing address dropdowns. HTML Add {{depend buyer_mobile}}<br/>Buyer Mobile# {{var buyer_mobile}}{{/depend}}. This format is used in many places like Order View, Address Display etc. PDF Add {{depend buyer_mobile}}<br/>Buyer Mobile# {{var buyer_mobile}}{{/depend}}|. This format is used in PDF invoices, shipments etc. Javascript Template Add <br/>Buyer Mobile#{buyer_mobile}. This is used in admin add/edit address area. After saving these in the configuration, the new address format should be visible.
Create Account Address First to show address in the magento create account form we need to make changes to customer\form\register.phtml (magento 1.6- version) or persistent\customer\form\register.phtml (magento 1.6+ version). If your using a module we will overwrite these files and make changes, if your not using a module you can make these changes directly. To overwrite, in your module’s layout xml file
<customer_account_create> <reference name='customer_form_register'> <action method='setTemplate'><template>address/persistent/customer/form/register.phtml</template></action> </reference> </customer_account_create>
Next in the phtml file regsiter.phtml created we will copy the default magento register.phtml contents and add our new field. First in the beginning of the file add this code, which will show all the address fields.
<?php $this->setShowAddressFields(true);?>
Next we need to add our new field, place this code where you want to show the new field
<li class="fields"> <div class="field"> <label for="buyer_mobile" class="required"><em>*</em><?php echo $this->__('Buyer Mobile') ?></label> <div class="input-box"> <input type="text" name="buyer_mobile" value="<?php echo $this->htmlEscape($this->getFormData()->getData('buyer_mobile')) ?>" title="<?php echo $this->__('Buyer Mobile') ?>" id="buyer_mobile" class="input-text required-entry" /> </div> </div> </li>
After this the new field added should be automatically saved to the database. You can view the new field in the admin and my account area.
Edit Address Next, in the My Account -> Edit Address form we need to add the the new field as well. For this we need to edit the customer\address\edit.phtml file. In the module’s layout xml file put in this code
<customer_address_form> <reference name='customer_address_edit'> <action method='setTemplate'><template>address/customer/address/edit.phtml</template></action> </reference> </customer_address_form>
and in the new edit.phtml file put in the form field where every required
<li class="fields"> <div class="field"> <label for="buyer_mobile" class="required"><em>*</em><?php echo $this->__('Buyer Mobile') ?></label> <div class="input-box"> <input type="text" name="buyer_mobile" value="<?php echo $this->htmlEscape($this->getAddress()->getData('buyer_mobile')) ?>" title="<?php echo $this->__('Buyer Mobile') ?>" id="buyer_mobile" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('telephone'); ?> required-entry" /> </div> </div> </li>
Now editing/saving the Govt ID will work.
Checkout Billing/Shipping Step
Now, we will see what we need to do for adding the fields in shipping and billing steps of checkout page.
For this need to make changes to the checkout/onepage/billing.phtml and checkout/onepage/shipping.phtml files. To do this in the module’s layout xml file put in this code
<checkout_onepage_index> <reference name='checkout.onepage.billing'> <action method='setTemplate'><template>address/checkout/onepage/billing.phtml</template></action> </reference> <reference name='checkout.onepage.shipping'> <action method='setTemplate'><template>address/checkout/onepage/shipping.phtml</template></action> </reference> </checkout_onepage_index>
Next in the shipping.phtml and billing.phtml files need to add the field. Add this code in billing.phtml file
<li class="buyer_mobile"> <div class="buyer_mobile_field"> <div class="left_label"><label for="billing:buyer_mobile" class="required"><em>*</em><?php echo $this->__('Buyer Mobile') ?></label></div> <div class="buyer_mobile_content"> <input type="text" title="<?php echo $this->__('Buyer Mobile') ?>" name="billing[buyer_mobile]" id="billing:buyer_mobile" value="<?php echo $this->htmlEscape($this->getAddress()->getBuyerMobile()) ?>" class="input-text validate-one-required-by-group required-group-1 validate-digits validate-length minimum-length-11 maximum-length-11" /> </div> </div> </li>
and add this code in shipping.phtml file
<li class="buyer_mobile"> <div class="buyer_mobile_field"> <div class="left_label"><label for="billing:buyer_mobile" class="required"><em>*</em><?php echo $this->__('Buyer Mobile') ?></label></div> <div class="buyer_mobile_content"> <input type="text" title="<?php echo $this->__('Buyer Mobile') ?>" name="billing[buyer_mobile]" id="billing:buyer_mobile" value="<?php echo $this->htmlEscape($this->getAddress()->getBuyerMobile()) ?>" class="input-text validate-one-required-by-group required-group-1 validate-digits validate-length minimum-length-11 maximum-length-11" /> </div> </div> </li>
Next, we need to add this xml code to our module config.xml file
<fieldsets> <sales_convert_quote_address> <buyer_mobile> <to_order_address>*</to_order_address> <to_customer_address>*</to_customer_address> </buyer_mobile> </sales_convert_quote_address> <customer_address> <buyer_mobile> <to_quote_address>*</to_quote_address> </buyer_mobile> </customer_address> </fieldsets> </global>
Next we need to add govt_id column in the tables sales_flat_order_address, sales_flat_quote_address. To do this in your module’s sql file
$tablequote = $this->getTable('sales/quote_address'); $installer->run(" ALTER TABLE $tablequote ADD `buyer_mobile` varchar(255) NOT NULL "); $tablequote = $this->getTable('sales/order_address'); $installer->run(" ALTER TABLE $tablequote ADD `buyer_mobile` varchar(255) NOT NULL ");
Now, if a new address is created from the checkout step the new field will be added to the database and show up the order view.
These are all the places where the address shows up. The new field we have added will automatically show up in emails, pdfs etc.
相关推荐
基于labview的声卡数据采集系统与分析设计毕业论文
Android Studio实现学生信息管理系统源码(高分项目).zip个人经导师指导并认可通过的高分大作业项目,评审分98分,项目中的源码都是经过本地编译过可运行的,都经过严格调试,确保可以运行!主要针对计算机相关专业的正在做大作业的学生和需要项目实战练习的学习者,资源项目的难度比较适中,内容都是经过助教老师审定过的能够满足学习、使用需求,如果有需要的话可以放心下载使用。 Android Studio实现学生信息管理系统源码(高分项目).zipAndroid Studio实现学生信息管理系统源码(高分项目).zipAndroid Studio实现学生信息管理系统源码(高分项目).zipAndroid Studio实现学生信息管理系统源码(高分项目).zipAndroid Studio实现学生信息管理系统源码(高分项目).zipAndroid Studio实现学生信息管理系统源码(高分项目).zipAndroid Studio实现学生信息管理系统源码(高分项目).zipAndroid Studio实现学生信息管理系统源码(高分项目).zipAndroid Studio实现学生信息管理
个人毕业设计 - 基于树莓派、OpenCV及Python语言的人脸识别.zip
考虑时变压力角和时变齿侧间隙的直齿轮六自由度平移-扭转耦合非线性动力学程序,包括时域图,相图,FFT图,庞加莱图,分岔图。 要想学好齿轮动力学,需要有扎实的齿轮动力学理论和非线性动振动理论。 齿轮啮合刚度建模是齿轮动力学求解的第一步。
tdm64-gcc-10.3.0-2.exe.zip。资源来源于网络分享,如有侵权请告知!
安卓项目源码Android broadcast电池电量显示源码提取方式是百度网盘分享地址
汽车中间件市场调研报告:2023年全球汽车中间件市场销售额达到了78亿美元 在数字化转型的浪潮中,汽车中间件作为连接硬件与软件的关键桥梁,正引领着汽车行业的新一轮变革。随着全球汽车产业的快速发展,中间件市场规模持续扩大,展现出前所未有的增长潜力。然而,面对复杂多变的市场环境和不断涌现的新技术,企业如何精准把握市场脉搏,实现可持续发展?本文将深入探讨全球及中国汽车中间件市场的现状、趋势及竞争格局,为您揭示咨询的重要性。 市场概况: 根据QYResearch(恒州博智)的统计及预测,2023年全球汽车中间件市场销售额达到了78亿美元(约7803百万美元),预计2030年将达到156亿美元(约15630百万美元),年复合增长率(CAGR)为10.3%(2024-2030)。这一数据不仅彰显了中间件市场的强劲增长动力,也预示着未来巨大的市场空间。 技术创新与趋势: 随着自动驾驶、车联网等技术的不断发展,汽车中间件正面临着前所未有的技术挑战与机遇。新一代中间件需要具备更高的实时性、更低的延迟以及更强的数据处理能力,以满足复杂多变的汽车应用场景。同时,云计算、大数据、人工智能等技术的融合应用,将进
计算机系毕业设计
亲测可用与黑莓OS6和OS7的文件管理器,测试型号9788、9900、9981
基于STM8单片机的编程实例,可供参考学习使用,希望对你有所帮助
超全知识点,用来学习都可以。
驾驶行为风险预测。2018平安产险数据建模大赛 驾驶行为预测驾驶风险Fork或借鉴请注明出处 @ChungKing . Thx比赛链接2018平安产险数据建模大赛 驾驶行为预测驾驶风险数据下载秩第五周 第六周 相关文章http://blog.51cto.com/yixianwei/2120336执照版权所有 (c) ChungKing。保留所有权利。根据MIT许可证授权。
元旦烟花html
在21世纪的科技浪潮中,人工智能(AI)无疑是最为耀眼的明星之一,它以惊人的速度改变着我们的生活、工作乃至整个社会的运行方式。而在人工智能的广阔领域中,大模型(Large Models)的崛起更是开启了智能技术的新纪元,引领着AI向更加复杂、高效、智能的方向发展。本文将深入探讨人工智能大模型的内涵、技术特点、应用领域以及对未来的影响。 一、人工智能大模型的内涵 人工智能大模型,顾名思义,是指具有庞大参数规模和数据处理能力的AI模型。这些模型通过深度学习算法,在海量数据上进行训练,能够学习到丰富的知识表示和复杂的模式识别能力。与传统的小型或中型模型相比,大模型在理解自然语言、生成高质量内容、进行跨模态信息处理等方面展现出前所未有的优势。它们不仅能够执行特定的任务,如图像识别、语音识别,还能进行创造性的工作,如文本生成、音乐创作,甚至在某些情况下展现出接近或超越人类的智能水平。 二、技术特点 海量数据与高效训练:大模型依赖于庞大的数据集进行训练,这些数据涵盖了广泛的主题和情境,使得模型能够学习到丰富的语义信息和上下文理解能力。同时,高效的训练算法和硬件加速技术,如TPU(Tensor Processing Unit)和GPU,使得大规模模型的训练成为可能。 自注意力机制与Transformer架构:许多领先的大模型采用了Transformer架构,特别是其自注意力机制,这种设计使得模型在处理序列数据时能够捕捉到长距离依赖关系,极大地提高了模型的表达能力和泛化能力。 多任务学习与迁移学习:大模型通常具备多任务学习的能力,即在一次训练中同时学习多个任务,这有助于模型学习到更通用的知识表示。此外,迁移学习使得这些模型能够轻松适应新任务,只需少量额外数据或微调即可。
2020中国高校计算机大赛·华为云大数据挑战赛-热身赛队名无能万金油2020中国高校计算机大赛·华为云大数据挑战赛--热身赛热身赛Rank 7CSDN博客我的博客 (建议直接打开热身赛code.ipynb,里面有详细说明)比赛地址华为云大数据挑战赛--热身赛赛题说明热身赛题——交通流量预测随着电子信息和移动通信技术高速发展和不断融合,人工智能在各个领域都相继取得了巨大的突破,城市智能体也应运而生,而城市交通又是城市智能体的核心。交通流量数据既是城市交通中的基础数据,又是反应交通状况的重要指标之一,准确预测交通流量对城市交通具有重大意义。本题以交通流量预测为目标,邀请各个队伍以历史交通流量数据建立对应的算法模型,预测目标流量数据,通过预测值和真实值之间的对比得到预测准确率,以此来评估各队伍所提交的预测算法。要求lightgbm 2.3.0学习熊猫==0.24.2泡菜numpy全面质量管理scipy ==>1.1.0##数据在trian文件夹下:1月12日 ~2月8日 各路口数据train/01-12/chongzhi_beie
使用Hadoop、Spark等实现的大数据平台项目大数据项目集1. 基于Hadoop的离线用户行为日志分析(weblog)技术栈Hadoop豆 点击流数据处理 点击会话流模型构建 Hive明细表构建 用户行为指标分析2. 基于Akka实现RPC通信(akka_rpc)技术栈Akka 模拟Hadoop集群间通信 模拟Spark集群间通信 模拟Yarn通信3. 广告数据管理平台(dmp)技术栈Spark、Scala 广告日志ETL 报表统计 用户画像构建 广告标签统计 DMP结果入库HBase4. 基于Spark MLLib实现个性化推荐(mllib)技术栈Spark、ScalaMovieLens 数据模型构建 冷启动启动时用户随机对10部电影评分 切分数据集 ALS模型构建 模型评估 个性化推荐5. 基于Flink对CDN日志分析(flink-train)技术栈Flink、Scala 模拟Kafka生产者生成日志数据 CDN日志分析
数据可视化大屏展示维兹前言提到数据大屏,通常大家的印象就是各种图表、表格的数据展示,然后不断地轮询后端接口。对于前端开发者来说,更多的关注点在于布局问题、图表的兼容性问题以及窗口变化后图表样式问题。对于后端来说,主要考虑的是如何在不断的请求中减轻服务器的压力。但实际上,数据大屏的需求还远不止于此前端发布后应当可以作为应用直接运行,而不需要手动输入地址进行预览。 需要减轻服务器的压力,避免频繁的数据请求。 当前后端任何一方或双方都离线的情况下,数据仍能正常运行。 需要日志的存储,以便随时查看问题。 需要调用系统的能力和跨域调用API,以增加数据展示的灵活性。解决方案我采用了GO和lorca的方式来解决以上问题特征打包体积轻量,仅20MB。使用无头浏览器lorca,可自定义Chrome和JavaScript之间的交互。支持交叉编译到Windows和Mac系统。离线状态下也可以正常运行。可以运行本地服务,减轻服务器压力。编译速度快,运行性能优秀。依赖项该项目的依赖项如下Go 1.20+节点 14.8+整体方案演示下载对应的安装包
仅限个人学习,禁止商业用途!
cmn.txt的英文句子经过分词、转为小写处理得到的结果存放的文件
基于PLC控制密码锁.doc