`
haohappy2
  • 浏览: 325859 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

How to add custom fields in magento

 
阅读更多

Magento Provides the default customer registration form with very few fields like name,email,pwd etc. But in realtime we need to get more details from the customer during registration. In order to achieve this we may have to create custom module that extends the magento customer module.

Step 1: We Start with Our module activation file first it just specifies the module name its location and Active Status. This file must be placed in app/etc/modules/ directory as app/etc/modules/Mydons_Customer.xml

Step 2: Next we need to create our config.xml file. Here we specify the model class name of our module. Then in the global tag we specify our custom field for our customer. Here iam creating a custom field called mobile.
Our config.xml should be placed in the directory app/code/local/Mydons/Customer/etc/config.xml


Under the resources tag I have added the customer setup class name. The only model class available in this module is Mydons_Customer_Model_Entity_Setup. This class is a subclass of Mage_Customer_Model_Entity_Setup class.

Step 3: Now We need to create a Model Class we specified in the Previous step. This class contains only a single method called getDefaultEntities. You can copy the getDefaultEntities Method from the Base class Mage_Customer_Model_Entity_Setup and paste it in our model class Mydons_Customer_Model_Entity_Setup. This File must reside in our Model directory app/code/local/Mydons/Customer/Model/Entity/Setup.php

Step 4: We are going to add our custom field mobile in the customer array of the getDefaultEntities Method as shown below

Step 5: In Our Final Step we need to create our setup file which is a install script in the directory app/code/local/Mydons_Customer/sql/customerattribute_setup/mysql4-install-0.1.0.php

Here in the first part i have added the customer attribute to EAV table with attribute Properties. For Magento version 1.3 this part alone is enough to make the custom field save to the database. However for latest versions like Magento 1.4 and 1.5 we need an additional step to save in Customer Attribute table. First we get the Eav attribute using its attribute code and then we need to Set in which forms the custom field is going to be used.
After this Step we can add our custom field in the register and account edit template files. The custom field will now be saved to the database.

Compatability : Magento 1.4 and Magento 1.5

http://mydons.com/category/framework/magento/

分享到:
评论

相关推荐

    Magento2 CookBook

    Chapter 3, Enabling Performance in Magento 2, explains how to configure different types of caching options. In Magento 2, the Full Page Cache (FPC) can be handled by Varnish to give your store a ...

    Magento 2 Cookbook

    Chapter 3, Enabling Performance in Magento 2, explains how to configure different types of caching options. In Magento 2, the Full Page Cache (FPC) can be handled by Varnish to give your store a ...

    Magento 自定义后台menu Insert dynamical menu in Magento’s Admin

    最后,为了让Magento知道你的模块存在并启用这个功能,记得在`app/etc/modules/Custom_Module.xml`中声明模块,并设置`active`为`true`。 ```xml <Custom_Module> <active>true <codePool>local </Custom_...

    The Definitive Guide to Magento (Apress出品 Magento权威指南)

    ### Magento权威指南 #### 书籍概述 《Magento权威指南》是由Adam McCombs与Robert Banh共同编著的一本深入探讨Magento电商平台的技术手册。该书由Apress出版社于2009年出版发行,旨在为读者提供一个全面、系统的...

    Magento 2 Beginners Guide

    You’ll start by getting a general understanding of what Magento is, why and how you should use it, and whether it is possible and feasible to migrate from an old web store to Magento 2. As you work ...

    magento创建自定义页面 (Bestseller实例) Bestseller products in Magento

    Magento是一款强大的开源电子商务平台,它提供了丰富的功能和高度的可定制性。在Magento中创建自定义页面是一项常见的任务,这通常涉及到对系统架构的理解、模板文件的编辑以及URL的配置。在这个实例中,我们将深入...

    wp_custom_menu-1.2.5.rar_magento_magento custom menu

    标题中的"wp_custom_menu-1.2.5.rar"指的是一个专门为Magento设计的定制菜单插件的版本号为1.2.5的压缩包文件。这个插件允许用户根据自己的需求自定义商店的导航菜单,以提供更好的用户体验和更高效的网站导航。 在...

    The Definitive Guide to Magento.pdf

    ### Magento 全面指南知识点概览 #### 一、引言 《Magento全面指南》是电子商务平台Magento的权威参考书籍,由Adam McCombs与Robert Banh共同编写。本书不仅适用于初学者,对于有一定经验的开发者和技术人员也同样...

    magento 评论的导入导出

    “HOW TO SETUP ADVANCED PROFILE IN MAGENTO.pdf”文档详细阐述了如何在Magento中设置高级导入导出配置。这份指南通常会涵盖以下步骤: 1. 登录Magento后台,找到“System”菜单下的“Data Transfer”选项。 2. ...

    magento快速复制网站_magento_magento快速复制站_

    这里,`/path/to/source/magento/`是源站点的Magento根目录,`/path/to/destination/`是目标服务器的目录。 在新服务器上安装MySQL,并导入先前备份的数据库: ```bash mysql -u [new_username] -p[new_password] ...

    Magento 添加后台管理 addColumn

    "Magento添加后台管理addColumn"这个主题主要涉及的是如何在Magento的后台管理面板自定义添加新的数据列,以展示更多店铺运营的相关信息。这通常涉及到对Magento的MVC(Model-View-Controller)架构的理解,以及对...

    custom-reports, 使用SQL定制Magento报告.zip

    custom-reports, 使用SQL定制Magento报告 使用Google图表 API 定制Magento报告使用custom或者使用magento管理网格( ),轻松创建报表,并使用magento来显示它们。 功能报告结果表定义列配置或者允许自动配置的能力。...

    Ajax-Magento-ajax-add-to-cart.zip

    Ajax-Magento-ajax-add-to-cart.zip,[模块magento 1]magento ajax添加到购物车-ajoter vos produits au panier en ajax/感谢ajax将您的产品添加到购物车,ajax代表异步javascript和xml。它是多种web技术的集合,包括...

    [Magento] Magento 扩展开发入门教程 (英文版)

    Get a hands-on introduction to custom shipping and payment methods ☆ 出版信息:☆ [作者信息] Branko Ajzele [出版机构] Packt Publishing [出版日期] 2013年09月25日 [图书页数] 128页 [图书语言] 英语...

    Magento: 后台添加预览按钮 View product in frontend from Magento admin

    这篇博客“Magento:后台添加预览按钮 View product in frontend from Magento admin”主要探讨了如何通过自定义开发来实现这一功能,让管理员能够快速检查商品在网站前台的显示状态。 在Magento中,通常管理员需要...

    Guide to Programming with magento 编程手册

    通过以上内容可以看出,《Guide to Programming with Magento》是一本针对Magento开发者非常实用的手册,不仅提供了基础知识的讲解,还深入探讨了Magento的核心技术和高级功能,对于希望提升自己Magento开发技能的...

    magento数据结构分析

    标题:“Magento数据结构分析” 描述:“Magento数据字典”提供了对Magento系统中各种数据库表的深入理解,这对于理解和优化Magento的性能至关重要。 一、Magento数据结构解析 Magento是一款功能强大的电子商务...

Global site tag (gtag.js) - Google Analytics