Return to Snippet

Revision: 51747
at October 3, 2011 16:46 by etechblog


Initial Code
<?php
$installer = $this;
$installer->startSetup();
$this->addAttribute('customer', 'school', array(
    'type' => 'int',
    'input' => 'select',
    'label' => 'School',
    'global' => 1,
    'visible' => 1,
    'required' => 0,
    'user_defined' => 1,
    'default' => '0',
    'visible_on_front' => 1,
        'source'=> 'profile/entity_school',
));
if (version_compare(Mage::getVersion(), '1.6.0', '<='))
{
      $customer = Mage::getModel('customer/customer');
      $attrSetId = $customer->getResource()->getEntityType()->getDefaultAttributeSetId();
      $this->addAttributeToSet('customer', $attrSetId, 'General', 'school');
}
if (version_compare(Mage::getVersion(), '1.4.2', '>='))
{
    Mage::getSingleton('eav/config')
    ->getAttribute('customer', 'school')
    ->setData('used_in_forms', array('adminhtml_customer','customer_account_create','customer_account_edit','checkout_register'))
    ->save();
}
$installer->endSetup();

Initial URL
http://www.excellencemagentoblog.com/customer-registration-fields-magento1-6

Initial Description


Initial Title
Magento - Add Custom Fields to Customer Profile

Initial Tags
magento

Initial Language
PHP