Magento – how to get value form joinAttribute from eav_attribute_option_value table

custom-optionscustomer-grid

i installed a plugin for add customer fields.
after that i have added a field name "status" to customer form.
and status field is dropdown.
now i want to display that in customer grid.
for that i have added

->joinAttribute('status', 'customer/status', 'default_billing', null, 'left')

in app/code/core/Mage/Adminhtml/Block/Customer/Grid.php

in _prepareCollection() so collection is now $collection =

Mage::getResourceModel('customer/customer_collection')
            ->addNameToSelect()
            ->addAttributeToSelect('email')
            ->addAttributeToSelect('created_at')
            ->addAttributeToSelect('group_id')
            ->joinAttribute('status', 'customer/status', 'default_billing', null, 'left')
            ->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')
            ->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left')
            ->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
            ->joinAttribute('billing_region', 'customer_address/region', 'default_billing', null, 'left')
            ->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left');

and also added in _prepareColumns()

$this->addColumn('status', array(
    'header'    => Mage::helper('customer')->__('customer status'),
    'index'     => 'status',
));

it's display option_id. but i want to display option value.

Thanks in advance!

Best Answer

Make your column look like this:

$attribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'status');
$options = $attribute->getSource()->getAllOptions();

$this->addColumn('status', array(
    'type'      => 'options',
    'header'    => Mage::helper('customer')->__('customer status'),
    'index'     => 'status',
    'options'   => $options
));
Related Topic