0

I want to display customer name based on customer id in my custom module grid column.

Currently customer id only showing in the grid column. Please check attached image. enter image description here

1

1 Answer 1

0

You can do this by adding renderer in you column. here is the example.

In your _prepareColumns() function of the Grid.php file add renderer in your Seller column

    protected function _prepareColumns() {
   //other columns data
  $this->addColumn('seller_id', array(
    'header'    => Mage::helper('adminhtml')->__('Seller Name),
    'align' => 'center',
    'index'     => 'seller_id',
    'type'  => 'text',
    'renderer' => 'Namespace_ModuleName_Block_Adminhtml_Seller_Grid_Renderer_SellerName',     
 ));
 }

Create SellerName.php file in this location

app/code/{{your_code_pool}}/Namespace/ModuleName/Block/Adminhtml/Seller/Grid/Renderer/SellerName.php

and Add this code.

class Namespace_ModuleName_Block_Adminhtml_Seller_Grid_Renderer_SellerName extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
    {
          public function render(Varien_Object $row)
          {
             return "your logic here to return seller name."
          }
    }

Replace Namespace_ModuleName with your Namespace and ModuleName.

2
  • But in this case search by name not working . Only search by id is working
    – Hussain
    Commented Jan 11, 2018 at 6:24
  • For that you have to add 'filter_condition_callback' option in column in grid.php file. Commented Jan 11, 2018 at 8:32

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.