I'm using the code below to add an SKU field to the Orders page in the Magento Backend.

For the most part, the code works fine. SKU's are displayed in a column in the Orders page.

However, I've experienced an issue when searching orders using Magento's backend filter. When inputting a date and searching, the admin is redirected to the dashboard, and trying to access 'Sales > Orders' gives the following error:

There has been an error processing your request Exception printing is disabled by default for security reasons. Error log record number: 1404938437855

Code I'm using in grid.php (in app/code/core/mage/adminhtml/block/sales/order/grid.php - is this the right place for this code?)

public function callback_skus($value, $row, $column, $isExport) {
    $increment_id = $value;
    $_order = Mage::getModel('sales/order')->loadByIncrementId($increment_id);
    $_items = $_order->getAllItems();
    foreach ($_items as $item) {
        $skus .= $item->getSku()."<br/>";
    return $skus;

public function filter_skus($collection, $column) {
    if (!$value = $column->getFilter()->getValue()) {
        return $this;

        "sku like ?"
        , "%$value%");

    return $this;


and then

protected function _prepareCollection()

    $collection = Mage::getResourceModel($this->_getCollectionClass())
                'skus'  => new Zend_Db_Expr('group_concat(`sales/order_item`.sku SEPARATOR ",")'),
    return parent::_prepareCollection();

and finally

    $this->addColumn('sku', array(
             'header' => Mage::helper('sales')->__('SKU'),
             'index' => 'increment_id',
             'frame_callback' => array($this, 'callback_skus'),
             'filter_condition_callback' => array($this, 'filter_skus'),


I also tried using this code:

public function filter_skus($collection, $column) {
    if (!$value = $column->getFilter()->getValue()) {
        return $this;
    $this->getCollection()->getSelect()->join( array('table_alias'=>'sales_flat_order_item'), 'main_table.entity_id = table_alias.order_id',array('table_alias.sku'));
    $this->getCollection()->getSelect()->where("sku like ?", "%$value%");

    return $this;
  • go to var/report and open 1404938437855 . what is the error log ? – Manashvi Birla Apr 12 '16 at 4:51

I have seen you are modifying core files, it's bad idea never touch core files, Here is great tutorial for it :

  2. How to extend Magento Order Grid?

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.