I had encrypted customer's firstname ,lastname and email and need to decrypt data to show in front end.
I will be Overriding public function getCustomer() located at app/code/core/Mage/Model/Session.php file. Customer Data retrieved from $customer = Mage::getModel('customer/customer') ->setWebsiteId(Mage::app()->getStore()->getWebsiteId()); $customer->load($this->getId());


When ever i use print_r($customer) to print data of logged in customer i get Mage_Customer_Model_Customer Object.


I want to replace decrypted value of firstname,lastname and email with an array $customer['_origData:protected'] and $customer['_Data:protected'] since methods are protected so i have converted object into an array and converted again into an Object after passing decryption function , but converted Object is without protected methods. I'm getting Fatal Error when converted Object is passed to function $this->setCustomer($customer);

What I want Replace three encrypted values firstname , lastname and email in Object Mage_Customer_Model_Customer Object

Basic Question is :- How to Replace values in an object ?

2 Answers 2


Use setData($key, $value) to change _data and setOrigData($key, $value) to change _origData.

Also, instead of setData('firstname', 'John') you can always write setFirstname('John'), even though the method is not declared, thanks to the "magic" getters and setters in Varien_Object.


I don't exactly understand your question, but if you want to convert an array to a stdClass instance here is a simple way to do it.

$encoded = json_encode($arr);
$obj = json_decode($encoded);
  • I have encrypted data of customer and stored data into database. While editing information i get encrypted data so need to show decrypted means original. $customer = Mage::getModel('customer/customer') ->setWebsiteId(Mage::app()->getStore()->getWebsiteId()); print_r($customer); if ($this->getId()) { Above coding returns me stdClass object as [firstname] => XPPFukjwBbgUivv0MbvKN6SXB98VTRK1 [lastname] => 6Iyu6a4RZcE+m4CjwT99wQ so i want to decrypt data and again convert it into object by passing $this->setCustomer($customer); Commented Feb 28, 2014 at 8:59

Your Answer

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

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