I'm currently running Magento ver. 1.7.0.2
I want to add a custom attribute called memberDays to all customers. The catch is I want it to be an associative array or object.
1.)What is the best practice to do this? (My attempted code is below)
2.)Where should this go so that it is not on my front-end.
If you could explain why also, it would be much appreciated I love learning new stuff everyday ^_^
Ex. (What I want customers to have as an attribute)
memberDays = {
Silver => 0,
Gold => 0,
Platinum => 0
}
I've only been successful in changing attributes for both Products and Customers as well as adding Product Attributes in the backend Admin Panel. Unfortunately you can't add customer attributes in the Admin panel so I'm here requesting your help!
$installer = $this;
$installer->startSetup();
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId = $setup->getEntityTypeId('customer');
$attributeSetId = $setup->getDefaultAttributeSetId($entityTypeId);
$attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
$setup->addAttribute('customer', 'member_days', array(
'input' => 'text',
'type' => 'string',
'label' => 'Days Remaining for Membership',
'visible' => 1,
'required' => 0,
'user_defined' => 0,
'membership_array' => (Silver => 0, Gold => 0, Platinum => 0)
));
$setup->addAttributeToGroup(
$entityTypeId,
$attributeSetId,
$attributeGroupId,
'member_days',
'999' //Place this as Last Attribute
);
$setup->endSetup();