Pergunta

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

http://pastebin.com/7BheFhuD

Foi útil?

Solução

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:

<?php
    $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):

<?php
    $customerModel = Mage::getModel('customer/customer');
    $loggedInCustomer = Mage::getSingleton('customer/session')->getCustomer();
    $geeeeeciiiii = Mage::getModel('customer/customer')->load($this->getRequest()->getParam('id'));
?>
Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange
scroll top