0
我創建了一個用於客戶註冊的觀察者。在觀察者中保存自定義客戶屬性
它裏面我有以下代碼段。
public function customerRegistrationSuccess($observer)
{
$customer = $observer->getEvent()->getCustomer();
$deviceName="web";
//log written
$customer->setDevice_used($deviceName);
$customer->save();
//log written again
}
和我有代碼的安裝文件:
<?php $installer = $this;
$installer->startSetup();
$this->addAttribute('customer', 'device_used', array(
'label' => 'Device Used',
'visible' => 1,
'input' => 'text',
'type' => 'varchar',
'required' => 0,
"unique" => 0,
'position' => 120,
'sort_order'=> 80,
));
$attribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'device_used');
$attribute->setData('used_in_forms', array(
'adminhtml_customer',
'checkout_register',
'customer_account_create',
'customer_account_edit',
'adminhtml_checkout'
));
$attribute->setData('is_user_defined', 0);
$attribute->save();
$installer->endSetup();
?>
但正在創建沒有這樣的屬性。什麼可能是錯的?
在此先感謝。