首先, 使用setData()函數對其進行測試,以驗證您使用的是正確的屬性名稱。
$customer->setData('profession', 'some profession');er code here
二, 您是如何創建該屬性的? 我建議這樣做(在安裝/升級文件.PHP):
$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);
//drop attribute if it already exists (to avoid problems)
$setup->removeAttribute('customer', 'profession');
//now recreate the attribute
$this->addAttribute('customer', 'profession', array(
'type' => 'varchar',
'input' => 'text',
'label' => Mage::helper('core')->__("Customer profession"),
'global' => 1,
'visible' => 1,
'required' => 0,
'user_defined' => 1,
'visible_on_front' => 1));
//adding the attribute in backend Forms in case you want that
Mage::getSingleton('eav/config')
->getAttribute('customer', 'profession')
->setData('used_in_forms', array('adminhtml_customer', 'customer_edit'))
->save();
讓我知道,如果現在爲你工作。