I need to add country field to admin user creation.I have created that field.But I can't save that attribute value into database.For saving that new attribute I have used following observer event.
<admin_user_save_before>
<observers>
<marketplace>
<type>singleton</type>
<class>marketplace/observer_product</class>
<method>adminUserCountrySave</method>
</marketplace>
</observers>
</admin_user_save_before>
In Oberver
public function adminUserCountrySave($observer) {
$currentUserId = Mage::app()->getRequest()->getParam('user_id');
$currentUserCountry = Mage::app()->getRequest()->getParam('user_country');
$userData = Mage::getModel('admin/user')->load($currentUserId);
$userData->setUserCountry($currentUserCountry)->save();
}
But it is not working, it shows Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 65488 bytes) in D:\xampp\htdocs\SVEP3403\lib\Zend\Db\Select.php on line 421. Anyone know please help.
1 Answer 1
Try bellow code in observer
public function adminUserCountrySave($observer)
{
$user = $observer->getUser();
$currentUserCountry = Mage::app()->getRequest()->getParam('user_country',false);
$user->setUserCountry($currentUserCountry);
}
-
As an explanation to OP, basically you run out of memory because your
save()call is triggering theadmin_user_save_beforewhich triggers your observer and results in an infinite loop.Raphael at Digital Pianism– Raphael at Digital Pianism2016年01月23日 09:08:29 +00:00Commented Jan 23, 2016 at 9:08 -
Yes, I removed that save(), its working fine.Thanks for your help.Muthumahesh– Muthumahesh2016年01月23日 10:09:46 +00:00Commented Jan 23, 2016 at 10:09