Created
July 16, 2013 11:27
-
-
Save ajbonner/6007905 to your computer and use it in GitHub Desktop.
Create a Magento customer attribute and add it to admin forms
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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