1

In magento 1.9 how we can get comment column in sale -> orders with the latest comment e.g Customer is redirected to Paypal Any idea what will be the query for this?

1 Answer 1

7

Create your custom renderer, extended from renderer abstract:

class Vendor_Module_Block_Adminhtml_Widget_Grid_Column_Renderer_History extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{
    public function render(Varien_Object $row)
    {
        $orderId = $row->getId();
        $order = Mage::getModel('sales/order')->load($orderId);
        $history = $order->getStatusHistoryCollection()->getFirstItem();
        return $history->getComment();
    }
}

Then add new column to order grid, with this renderer:

$this->addColumn('history', array(
    'header' => Mage::helper('sales')->__('History status'),
    'type'  => 'text',
    'renderer' => new Vendor_Module_Block_Adminhtml_Widget_Grid_Column_Renderer_History()
));
3
  • Hi, @zhartaunik I need the same for Magento 2 Is that possible ?
    – Ask Xah
    May 5, 2019 at 9:49
  • Any help magento.stackexchange.com/q/298382/39050 Thanks @zhartaunik
    – zus
    Dec 12, 2019 at 11:53
  • Hi, Is it also possible to filter on this renderer? how would i need to implement this? Oct 8, 2020 at 13:00

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