1

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.

Magento 2
3,8347 gold badges58 silver badges109 bronze badges
asked Jan 23, 2016 at 6:47

1 Answer 1

2

Try bellow code in observer

public function adminUserCountrySave($observer)
 {
 $user = $observer->getUser();
 $currentUserCountry = Mage::app()->getRequest()->getParam('user_country',false);
 $user->setUserCountry($currentUserCountry);
 }
answered Jan 23, 2016 at 9:03
2
  • As an explanation to OP, basically you run out of memory because your save() call is triggering the admin_user_save_before which triggers your observer and results in an infinite loop. Commented Jan 23, 2016 at 9:08
  • Yes, I removed that save(), its working fine.Thanks for your help. Commented Jan 23, 2016 at 10:09

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.