madzacky
madzacky

Reputation: 286

How to add fields like mobile number and nickname in magento customer registration form

I want to add fields Mobile Number, Nickname, Profession in the customer registration form. I've a followed a tutorial, through that I am able to get address and fax from the customers and fetch them back, But if I try for mobile number and nickname, the data is not being saved in Database, what do I do now? Plz help me here.

Upvotes: 1

Views: 2277

Answers (2)

Pragnesh Rupapara
Pragnesh Rupapara

Reputation: 802

add mobile to customer registration,customer edit page etc. run following setup script from magento root.

define('MAGENTO', realpath(dirname(__FILE__)));

require_once MAGENTO . '/app/Mage.php';

Mage::app();



$installer = new Mage_Customer_Model_Entity_Setup('core_setup');

$installer->startSetup();

$vCustomerEntityType = $installer->getEntityTypeId('customer');
$vCustAttributeSetId = $installer->getDefaultAttributeSetId($vCustomerEntityType);
$vCustAttributeGroupId = $installer->getDefaultAttributeGroupId($vCustomerEntityType, $vCustAttributeSetId);

$installer->addAttribute('customer', 'mobile', array(
        'label' => 'Customer Mobile',
        'input' => 'text',
        'type'  => 'varchar',
        'forms' => array('customer_account_edit','customer_account_create','adminhtml_customer','checkout_register'),
        'required' => 0,
        'user_defined' => 1,
));

$installer->addAttributeToGroup($vCustomerEntityType, $vCustAttributeSetId, $vCustAttributeGroupId, 'mobile', 0);

$oAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'mobile');
$oAttribute->setData('used_in_forms', array('customer_account_edit','customer_account_create','adminhtml_customer','checkout_register'));
$oAttribute->save();

$installer->endSetup();

Upvotes: 1

nehra
nehra

Reputation: 158

you have to override Account controller of customer module.you will follow this link to override controller in magento.http://inchoo.net/tools-frameworks/how-to-extend-magento-core-controller/

Upvotes: 0

Related Questions