The following observer calling properly.I'm getting address ,customer object also .
but customer setting data not working(3rd line).even i tried save function on that.but it is also not working.
even i changed event name customer_address_save_before
.
here i created customer attribute company.
can you help any one?
<?xml version="1.0"?>
<config>
<modules>
<Gumbrands_Officename>
<version>0.1.0</version>
</Gumbrands_Officename>
</modules>
<global><models>
<officename>
<class>Gumbrands_Officename_Model</class>
</officename>
</models>
<events>
<customer_address_save_after>
<observers>
<Officename>
<type>singleton</type>
<class>officename/observer</class>
<method>updateCompany1</method>
</Officename>
</observers>
</customer_address_save_after>
</events>
</global>
</config>
Observer.php
<?php
class Gumbrands_Officename_Model_Observer
{
public function updateCompany1($observer)
{
$address = $observer->getCustomerAddress();
$customer= $address->getCustomer();
$customer->setData('company', $address->getData('company'));
}
}
?>
Best Answer
Please use
update the attribute using Resource model
because of when you haveusing save()
function ofcustomer model
then customerwill also call customer address model save function
that makeloop.
If you usegetResource()->saveAttribute()
function that only updateonly specific field
that means it does notcall address model save function