2

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!

1

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
));
  • Thanks Marius, i have added code but "customer status" column is blank now. and i have also check $options it's get proper value. – Sandeep Solanki Feb 26 '15 at 9:30
  • I've updated the answer. try with 'options' => $options instead of 'values' => $options – Marius Feb 26 '15 at 9:46
  • still it's blank column – Sandeep Solanki Feb 26 '15 at 11:19

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.