Magento 给用户customer ,添加一个属性

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', 'point', array(
    'input'         => 'text', //or select or whatever you like
    'type'          => 'int', //or varchar or anything you want it
    'label'         => 'Customer Point',
    'visible'       => 1,
    'required'      => 0, //mandatory? then 1
    'user_defined' => 1,
));

$setup->addAttributeToGroup(
 $entityTypeId,
 $attributeSetId,
 $attributeGroupId,
 'point',
 '100'
);

$oAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'point');
$oAttribute->setData('used_in_forms', array('adminhtml_customer')); 
$oAttribute->save();

$installer->endSetup();

你可能感兴趣的:(MAGENTO)