I would like to create custom drop down on all registration pages.
That drop down will have customer from another group.
This is my Pro.php file which is stored in app/code/local/KitchOff/CustomerRegistration/Model/entity and show different dropdown options
<?php
class KitchOff_CustomerRegistration_Model_Entity_Pro extends Mage_Eav_Model_Entity_Attribute_Source_Abstract {
public function getAllOptions() {
if ($this->_options === null) {
$this->_options = array();
$this->_options[] = array( 'value' => '', 'label' => 'Choose Option..' );
$this->_options[] = array( 'value' => 1, 'label' => 'Pro1' );
$this->_options[] = array( 'value' => 2, 'label' => 'Pro2' );
$this->_options[] = array( 'value' => 3, 'label' => 'Pro3' ); }
return $this->_options;
}
}
}
This is my config.xml which is stored in app/code/local/KitchOff/CustomerRegistration/etc
<?xml version="1.0"?>
<config>
<modules>
<KitchOff_CustomerRegistration>
<version>1.0.0</version>
</KitchOff_CustomerRegistration>
</modules>
<global>
<helpers>
<kitchoff_customerregistration>
<class>KitchOff_CustomerRegistration_Helper</class>
</kitchoff_customerregistration>
</helpers>
<resources>
<kitchoff_customerregistration_setup>
<setup>
<module>KitchOff_CustomerRegistration</module>
<class>Mage_Customer_Model_Resource_Setup</class>
</setup>
</kitchoff_customerregistration_setup>
</resources>
</global>
</config>
This is my install-1.0.0.php which is stored in app/code/local/CustomerRegistration/sql/kitchoff_customerregistration_setup/
startSetup();
$setup = Mage::getModel('customer/entity_setup', 'core_setup');
$setup->addAttribute('customer', 'pro', array(
'type' => 'int',
'input' => 'select',
'label' => 'Select PRO',
'global' => 1,
'visible' => 1,
'required' => 0,
'user_defined' => 1,
'default' => '0',
'visible_on_front' => 1,
'source'=> 'customerregistration/entity_pro'
));
if (version_compare(Mage::getVersion(), '1.6.0', '<=')) {
$customer = Mage::getModel('customer/customer');
$attrSetId = $customer->getResource()->getEntityType()->getDefaultAttributeSetId();
$setup->addAttributeToSet('customer', $attrSetId, 'Customer', 'pro');
}
if (version_compare(Mage::getVersion(), '1.4.2', '>=')) {
Mage::getSingleton('eav/config') ->getAttribute('customer', 'pro') ->setData('used_in_forms', array('adminhtml_customer','customer_account_create','customer_account_edit','checkout_register')) ->save();
}
$installer->endSetup();
This is my CustomerRegistration.xml which is stored on app/etc/modules
<?xml version="1.0"?>
<config>
<modules>
<KitchOff_CustomerRegistration>
<active>true</active>
<codePool>local</codePool>
<depends><Mage_Customer/></depends>
</KitchOff_CustomerRegistration>
</modules>
</config>
Best Answer
Ok, I just did it, here is how. Go to http://www.silksoftware.com/magento-module-creator/ and using its Module Creator to create a new module called "YourCustomerAttribute".
Modify located at app/design/frontend/base/default/template/persistent/customer/form/register.phtml and add:
If you want customer to be able to modify the attribute in customer panel, then modify app/design/frontend/base/default/template/customer/form/edit.phtm and add:
Refresh all caches.
You can also Get complete tutorial here.