1

I'm facing on the issue i mentioned that title. Partially i want to add the company attribute in back-end customer grid. So i add the attribute and it's worked well

However, all of sudden, the another values from name attribute disappeared.

And i already checked a sort of factors i've guessed

  • about database obviously
  • Connection issue from database(like joining table with customer information)
  • issue about method used when bringing the full name

First of all, the data about name are totally on 'customer_entity_varchar' table and also 'attribute_id' are set on accurately. And the method for bringing full name,i think, is function getFullCustomerName in app/code/core/Mage/Customer/Helper. Look at below.

/**
 * Retrieve full customer name from provided object
 *
 * @param Varien_Object $object
 * @return string
 */
public function getFullCustomerName($object = null)
{
    $name = '';
    if (is_null($object)) {
        $name = $this->getCustomerName();
    } else {
        $config = Mage::getSingleton('eav/config');

        if (
            $config->getAttribute('customer', 'prefix')->getIsVisible()
            && (
                $object->getPrefix()
                || $object->getCustomerPrefix()
                )
            ) {
                $name .= ($object->getPrefix() ? $object->getPrefix() : $object->getCustomerPrefix()) . ' ';
        }

        $name .= $object->getFirstname() ? $object->getFirstname() : $object->getCustomerFirstname();

        if ($config->getAttribute('customer', 'middlename')->getIsVisible()
            && (
                $object->getMiddlename()
                || $object->getCustomerMiddlename()
                )
            ) {
                $name .= ' ' . (
                    $object->getMiddlename()
                    ? $object->getMiddlename()
                    : $object->getCustomerMiddlename()
                );
        }

        $name .= ' ' . (
            $object->getLastname()
            ? $object->getLastname()
            : $object->getCustomerLastname()
        );

        if ($config->getAttribute('customer', 'suffix')->getIsVisible()
            && (
                $object->getSuffix()
                || $object->getCustomerSuffix()
                )
            ) {
                $name .= ' ' . (
                    $object->getSuffix()
                    ? $object->getSuffix()
                    : $object->getCustomerSuffix()
                );
        }
    }
    return $name;
}

I think it's not problem for method. because i didn't modify this function.

Lastly, this is my grid.php code in core/Mage/Adminhtml/block/customer

I think this part has problem such as setting attribute and joining table I insert company attribute on this file

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

I couldn't find addNameToSelect()method in my server. I just searched grep command

And,

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


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

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

What do you think of that? I can see like this,

enter image description here

1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.