I have a custom customer attribute, which isn't required, so it isn't set to every customer. but when I ask it if a customer has the data. (hasData('attribute')) if it doesn't exist it returns the currently logged in customer's data!

Customer 1: The attribute set is to 10. Customer 2: doesn't have it set.

if I log in with the Customer to and ask Customer 1 data, I get the correct data. but another way around : log in with Customer 1: ask for customer 2 data and get back Customer 1 data!

here is the source code I am using


1 Answer 1


First of all: your question is not very clear and your code is a mess. But I have an idea what's going wrong. It's this code:

    $customerModel = Mage::getModel('customer/customer');
    $loggedInCustomer = $customerModel->load(Mage::getSingleton('customer/session')->getId());
    $geeeeeciiiii = $customerModel->load($this->getRequest()->getParam('id'));

You cannot reuse the $customerModel variable. This would only work if load() returns a new object, but in Magento it doesn't. It loads the data for the object from the database and returns a reference to the same object. So in your code, the model's data gets loaded twice.

Use it in this way and most probably your code will work as expected (as long as all the other logic in your code works):

    $customerModel = Mage::getModel('customer/customer');
    $loggedInCustomer = Mage::getSingleton('customer/session')->getCustomer();
    $geeeeeciiiii = Mage::getModel('customer/customer')->load($this->getRequest()->getParam('id'));
  • Thanks! that works, and i know its messy it was a job made on haste by a beginner aka me. So yeah i need to to a lot of clean up.
    – NaGeL182
    Commented Apr 18, 2013 at 8:57

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.