1

hi I use this code to retrieve data from a customer's attribute called "pagamento"

if(Mage::getSingleton('customer/session')->isLoggedIn()) 
{
$customerId = Mage::getModel('customer/session')->getCustomer()->getId();
}
$customer = Mage::getModel('customer/customer')->load($customerId);
echo $customer->getpayment();

until now the attribute was a text box and returned the correct value to me. now I have to change the attribute which will be multiple choice

if I leave the code so I get a number and not the text of the multiple choice How can I get the text? Furthermore, if multiple values are selected, how can I get all the results? Thank you

1 Answer 1

0

Three choices:

1. $attributeText = $customer->getAttributeText('pagamento');

2. $attributeText = $customer->getResource()->getAttribute('pagamento')->getFrontend()->getValue($customer);

3. $attributeText = $customer->getResource()->getAttribute('pagamento')->getFrontend()->getAttribute()->getFrontendLabel();
3
  • Thanks for the reply the first solution gives no results the second works with the first value of multiple choice the third gives me the name of the attribute I will use the second one. Is there any way to get all the results of multiple choice?
    – Riccardo
    Commented Dec 10, 2017 at 10:23
  • The second one should gives you all the attribute values, check your attribute config and the selected values of this customer
    – PЯINCƎ
    Commented Dec 10, 2017 at 11:44
  • Thanks for the reply. I checked and only returns the first value of the multiple selection. For example, if I select them all the first one appears, if I remove the first one the second one appears
    – Riccardo
    Commented Dec 10, 2017 at 16:17

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.