Posted By

etechblog on 10/03/11


Tagged

magento


Versions (?)

Magento - Add Custom Fields to Customer Profile


 / Published in: PHP
 

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

  1. <?php
  2. $installer = $this;
  3. $installer->startSetup();
  4. $this->addAttribute('customer', 'school', array(
  5. 'type' => 'int',
  6. 'input' => 'select',
  7. 'label' => 'School',
  8. 'global' => 1,
  9. 'visible' => 1,
  10. 'required' => 0,
  11. 'user_defined' => 1,
  12. 'default' => '0',
  13. 'visible_on_front' => 1,
  14. 'source'=> 'profile/entity_school',
  15. ));
  16. if (version_compare(Mage::getVersion(), '1.6.0', '<='))
  17. {
  18. $customer = Mage::getModel('customer/customer');
  19. $attrSetId = $customer->getResource()->getEntityType()->getDefaultAttributeSetId();
  20. $this->addAttributeToSet('customer', $attrSetId, 'General', 'school');
  21. }
  22. if (version_compare(Mage::getVersion(), '1.4.2', '>='))
  23. {
  24. Mage::getSingleton('eav/config')
  25. ->getAttribute('customer', 'school')
  26. ->setData('used_in_forms', array('adminhtml_customer','customer_account_create','customer_account_edit','checkout_register'))
  27. ->save();
  28. }
  29. $installer->endSetup();

Report this snippet  

You need to login to post a comment.