Skip to content

Instantly share code, notes, and snippets.

@ajbonner
Created July 16, 2013 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajbonner/6007905 to your computer and use it in GitHub Desktop.
Save ajbonner/6007905 to your computer and use it in GitHub Desktop.
Create a Magento customer attribute and add it to admin forms
<?php
/* @var $installer Mage_Model_Customer_Entity_Setup */
$installer = $this;
/* @var $eavConfig Mage_Eav_Model_Config */
$eavConfig = Mage::getSingleton('eav/config');
$installer->startSetup();
$installer->addAttribute('customer', 'an_attr', array(
'type' => 'text',
'label' => 'An Attribute',
'visible' => false,
'required' => false
));
// look for form codes scattered around the mage codebase set using $model->setFormCode()
// here are some customer examples
$forms = array(
'adminhtml_customer',
'adminhtml_customer_address',
'customer_address_edit',
'customer_register_address',
'customer_account_create',
'customer_account_edit',
);
$eavConfig->getAttribute('customer', 'an_attr')
->setData('sort_order', 126)
->setData('used_in_forms', $forms)
->save();
$installer->endSetup();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment