4

I add columns to the product admin grid with addColumn.

Is it possible to show 2 custom attributes in 1 column.

Something like this:

$this->addColumn('lev_vdm_inkoop',
        array(
            'header'=> Mage::helper('catalog')->__('VDM'),
            'width' => '70px',
            'index' => array('lev_vdm_stock','lev_vdm_inkoop'),
    ));
4
  • Don't have time now, but the gist is to add a custom renderer to that grid column, using the $row object to get what attributes you need, as long as you define them in the grid collection object.
    – nevvermind
    Commented Apr 18, 2014 at 16:56
  • I have created a custom renderer for showing images. I will make a new custom renderer for this. Can I pass both attributes to the renderer or do I need to select the attributes in the renderer script? Commented Apr 18, 2014 at 20:52
  • Mage passes the $row param to your render() method. Check its data with var_dump($row->getData()). You should have all the row attributes/columns in there.
    – nevvermind
    Commented Apr 18, 2014 at 23:00
  • @RuudvanDijk did you ever fix this? I would be really interested in seeing a solution. Commented May 28, 2014 at 6:50

1 Answer 1

2

Here is how you can do it.
Rewrite the _prepareCollection method of the product grid and add this

    $collection->addExpressionAttributeToSelect(
        'lev_vdm_inkoop',
        "CONCAT_WS(' ', {{lev_vdm_stock}}, {{lev_vdm_inkoop}})",
        array('{{lev_vdm_stock}}'=>'lev_vdm_stock', '{{lev_vdm_inkoop}}'=>'lev_vdm_inkoop')
    );

After

->addAttributeToSelect('type_id');

Then in the _prepareColumns add this:

    $this->addColumn('lev_vdm_inkoop',
        array(
            'header'=> Mage::helper('catalog')->__('Label goes here'),
            'index' => 'lev_vdm_inkoop',
        ));

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.