0

i have add a customer attribute Salesman (select type, admin will asign salesman to customer at backend from list), any customer will have asigned a salesman who is responsible for contact with this customer.

Problem is, when i'm trying to access this attribute, i only get option_id number.

app/code/local/Mage/Adminhtml/Block/Customer/Grid.php
-----
 $this->addColumn('salesman', array(
            'header'    => 'Salesman',
            'index'     => 'salesman'
        ));

returns number not a text value.

accessing this way:

$customerObj  = Mage::getModel('customer/entity_attribute ')->load($customer_id);
$attr = $customerObj->getAttributes('salesman');

returns the same number "option_id".

Is there any way to access value of this specific attribute? I would not preffer to change all select attributes to return value :)

Can anyone help me with it? All previous replies for similar questions, wasn't helpful.

  • have you created customer attribute Salesman with source model? – Abdul Dec 18 '15 at 10:25
  • can you share you source model? – Abdul Dec 18 '15 at 10:26
0

Try

$attributeCode = 'salesman';

$customerObj  = Mage::getModel('customer/customer')->load($customer_id);

$textvalue = $customerObj->getResource()
            ->getAttribute($attributeCode)
                ->getSource()
                    ->getOptionText($this->getData($attributeCode));

OR

$customerObj  = Mage::getModel('customer/customer')->load($customer_id);

$attribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'salesman');

$text = $attribute->getSource()->getOptionText($customerObj->getSalesman());
  • 2nd solution works :) Thak you very very much – grabusik Dec 18 '15 at 13:03

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.