magento - Saving a custom customer attribute in observer -


i have created observer customer registration.

inside have following code segment.

public function customerregistrationsuccess($observer) {         $customer = $observer->getevent()->getcustomer();         $devicename="web";      //log written         $customer->setdevice_used($devicename);         $customer->save();        //log written again } 

and have install file code:

<?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();  ?> 

but no such attribute being created. possibly wrong?

thanks in advance.

i think set call in customerregistrationsuccess incorrect. should be

$customer->setdeviceused($devicename); 

alternatively use

$customer->setdata('device_used',$devicename); 

both achieve same thing.

if doesn't work need check install script ran correctly. check core_resource db table see if there's entry module , go there.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -