1

In magento CE 1.7.0.2

Add new column to sales order grid which have a most recent order comment.

Following code used to add column

protected function _prepareColumns()
{
    parent::_prepareColumns();

    // Add order comment to grid
    $this->addColumn('ordercomment', array(
        'header'       => Mage::helper('ordercomment')->__('Order Comment'),
        'index'        => 'ordercomment',
        'filter_index' => 'ordercomment_table.comment',
    ));

    // Fix integrity constraint violation in SELECT
    foreach ($this->_ambiguousColumns as $index) {
        if (isset($this->_columns[$index])) {
            $this->_columns[$index]->setFilterIndex('main_table.' . $index);
        }
    }

    return $this;
}

But comment shown in grid is first comment on order.

How most recent comment will show in this column?

  • Im wanting to do the same but so that is shows which vat rate the order has used i.e. 5% or 0% or 20% probably a drop down of the rates avaliable – user4052 Nov 22 '13 at 9:53
2

You may need to specify a more specific data type on the addColumn:

  • action
  • checkbox
  • concat
  • country
  • currency
  • date
  • datetime
  • input
  • interface
  • ip
  • longtext
  • massaction
  • number
  • options
  • price
  • radio
  • select
  • store
  • text
  • theme
  • wrapline

You will find all these types in /app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer

You can also make your own grid renderers the same way.


If you're making comments like these, question what you're doing is correct.

//Fix integrity constraint violation in SELECT

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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