Magento : add two column value in collection

many times we need to do operation on two column values and show in the admin panel. for this we have to follow these steps:
1. Add column in your Grid.php file:

addColumn('newcolumn', array(
          'header'    = Mage::helper('core')->__('NewColumn'),
          'align'       = 'left',
          'index'      = 'created_at',
          'type'       = 'action',
          'renderer' = new Namespace_Module_Block_Adminhtml_Renderer_Qty(),
      ));
?>

2. Now create a folder in the AdminHtml folder with name ‘Renderer’
3. Create a new php file with name ‘Qty.php’
4. Write below code in the Qty.php file:

getQty() - $row->getMinQty();
      return $remainingvalue;
    }
}
?>

Ref: http://www.magentocommerce.com/boards/viewthread/192232/#t239222
That’s all.


Comments

One response to “Magento : add two column value in collection”

Leave a Reply

Your email address will not be published. Required fields are marked *

*