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.

2

Try bellow code in observer

public function adminUserCountrySave($observer)
    {
        $user = $observer->getUser();
        $currentUserCountry =  Mage::app()->getRequest()->getParam('user_country',false);
        $user->setUserCountry($currentUserCountry);
    }
| improve this answer | |
  • 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. – Raphael at Digital Pianism Jan 23 '16 at 9:08
  • Yes, I removed that save(), its working fine.Thanks for your help. – Muthumahesh Jan 23 '16 at 10:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.