My code is as follows. Everything works fine except the filteration of new column which shows abandoned cart item names comma separately.
I have overridden the block Mage_Adminhtml_Block_Report_Shopcart_Abandoned_Grid.
protected function _prepareCollection()
{
$collection = Mage::getResourceModel('reports/quote_collection');
$filter = $this->getParam($this->getVarNameFilter(), array());
if ($filter) {
$filter = base64_decode($filter);
parse_str(urldecode($filter), $data);
}
if (!empty($data)) {
$collection->prepareForAbandonedReport($this->_storeIds, $data);
} else {
$collection->prepareForAbandonedReport($this->_storeIds);
}
$this->setCollection($collection);
Mage_Adminhtml_Block_Report_Grid_Shopcart::_prepareCollection();
//------------------ my modifications---------------
// This was done to show item names comma separately in the abandoned cart grid as a new column.
foreach($collection as $col)
{
$itemcollection = $col->getItemsCollection();
$products = array();
foreach ($itemcollection as $item)
{
$products[] = $item->getName();
}
$productname = implode( " , ", $products);
$col->setQuoteItemName($productname);
}
//------------------ my modifications---------------
return $this;
}
protected function _prepareColumns()
{
parent::_prepareColumns();
$this->addColumnAfter('quote_item_name', array(
'header' =>Mage::helper('reports_abandonedcart')->__('Item(s) Name'),
'index' =>'quote_item_name',
'filter_index'=>'sales_flat_quote.quote_item_name', // What should be here
'sortable' =>false
),'items_qty');
return Mage_Adminhtml_Block_Report_Grid_Shopcart::_prepareColumns();
}