سؤال

I want to get fullname of customers in magento back-end server.

enter image description here

I already brought the first name in index "NAME" and i want to join the lastname after first name.

protected function _prepareCollection()

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

protected function _prepareColumns()

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

How can i combine the first name and last name? Could you let me know. Thank you

هل كانت مفيدة؟

المحلول

User renderer

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

In you renderer block

<?php class Namespace_Modulename_Block_Renderer_Name extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract 
             { 

                 public function render(Varien_Object $row) { 

                     return $row->getFirstname.' '.$row->getLastname;

                 }

             }
?>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى magento.stackexchange
scroll top