Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8526669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:20:17+00:00 2026-06-11T08:20:17+00:00

Trying to add a column with a custom attribute to the admin customer grid

  • 0

Trying to add a column with a custom attribute to the admin customer grid in Magento v1.11

I’ve got this module set up like so:

config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <WACI_AdminHtmlExt>
            <version>0.1.0</version>
        </WACI_AdminHtmlExt>
    </modules>
    <global>
        <blocks>
            <adminhtml>
                <rewrite>
                    <customer_grid>WACI_AdminHtmlExt_Block_Customer_Grid</customer_grid>
                </rewrite>
            </adminhtml>
        </blocks>
    </global>
</config>

WACI/AdminHtmlExt/Block/Customer/Grid.php

<?php
/**
 * Adminhtml customer grid block
 *
 * @category   WACI
 * @package    WACI_AdminhtmlExt
 * @author     
 */

class WACI_AdminHtmlExt_Block_Customer_Grid extends Mage_Adminhtml_Block_Customer_Grid
{

    protected function _prepareCollection()
    {
        $collection = Mage::getResourceModel('customer/customer_collection')
            ->addNameToSelect()
            ->addAttributeToSelect('email')
            ->addAttributeToSelect('created_at')
            ->addAttributeToSelect('group_id')
            ->addAttributeToSelect('customer_id')
            ->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');

        $this->setCollection($collection);

        return parent::_prepareCollection();
    }


    protected function _prepareColumns()
    {
        $this->addColumn('entity_id', array(
            'header'    => Mage::helper('customer')->__('ID'),
            'width'     => '50px',
            'index'     => 'entity_id',
            'type'      => 'number',
        ));

       $this->addColumn('customer_id', array(
            'header'    => Mage::helper('customer')->__('Dynamics ID'),
            'width'     => '75px',
            'index'     => 'customer_id',
        ));

        //... rest of the function, removing a couple columns...


        return parent::_prepareColumns();
    }
}

Customer_Id, in this case is a custom attribute (tracking an internal customer id)… Not sure if I need to add logic to render this correctly? But its showing up in the admin just fine, otherwise.

I’ve read a couple articles that mention adding a renderer for new fields in grids like this – but just as many don’t mention it at all.

Not quite sure where to go from here –

Cheers


update

Just to clarify for those needing this solution:

class WACI_AdminHtmlExt_Block_Customer_Grid extends Mage_Adminhtml_Block_Customer_Grid
{

    /*protected function _prepareCollection()
        {
            $collection = Mage::getResourceModel('customer/customer_collection')
                ->addNameToSelect()
                ->addAttributeToSelect('email')
                ->addAttributeToSelect('created_at')
                ->addAttributeToSelect('group_id')
                ->addAttributeToSelect('customer_id')
                ->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');

            $this->setCollection($collection);

            return parent::_prepareCollection();
    }*/

    public function setCollection($collection)
    {
        $collection->addAttributeToSelect('customer_id');                    
        parent::setCollection($collection);
    }

    protected function _prepareColumns()
    {

        $this->addColumn('customer_id', array(
            'header'    => Mage::helper('customer')->__('Dynamics ID'),
            'width'     => '75px',
            'index'     => 'customer_id',
        ));

        $this->addColumnsOrder('customer_id','entity_id');

        parent::_prepareColumns();

        $this->removeColumn('billing_country_id');


        return $this;
    }
}

Is a what I finally landed up. Skipped the _prepareCollenctions() call.

Cheers

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:20:19+00:00Added an answer on June 11, 2026 at 8:20 am

    The problem is your return statement calling parent::_prepareCollection() combined with the fact you are extending the original class. By calling the parent class after your class you are replacing the collection object you created with the original. What you actually need to call is the parent of the class your overloading, which you can do like so…

    protected function _prepareCollection()
    {
        $collection = Mage::getResourceModel('customer/customer_collection')
            ->addNameToSelect()
            ->addAttributeToSelect('email')
            ->addAttributeToSelect('created_at')
            ->addAttributeToSelect('group_id')
            ->addAttributeToSelect('customer_id')
            ->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');
    
        $this->setCollection($collection);
    
        return Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to add a custom filter to my RadGrid. I have a column,
I am currently trying to add a custom column name to a property in
I am trying to create a custom module.When i click a module menu,empty grid
I got issue with custom library that I am trying to add to my
I'm trying to add new output column using synchronous custom data flow component(below is
Hi every One I am trying to add column in Mysql. My Sql Query
I am trying to add a new column into an SQLiteDatabase but every time
I am trying to add bootstrap drop down button in a column of jqGrid
I'm just trying to add 2 columns to customer table alter table CUSTOMER ADD
I have a custom function, and I am trying to created a persisted column

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.