Add a SKU column to the order grid in Magento 1.6.1


/ Published in: PHP
Save to your folder(s)

Add the below commented sections into the appropriate functions in your /app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php and you'll be good to go! This has been (personally) tested with 1.6.1.0


Copy this code and paste it in your HTML
  1. /* You will need to edit/replace your $collection declaration in _prepareCollection() */
  2.  
  3. $collection = Mage::getResourceModel($this->_getCollectionClass())
  4. ->join(
  5. 'sales/order_item',
  6. '`sales/order_item`.order_id=`main_table`.entity_id',
  7. 'skus' => new Zend_Db_Expr('group_concat(`sales/order_item`.sku SEPARATOR ",")'),
  8. 'names' => new Zend_Db_Expr('group_concat(`sales/order_item`.name SEPARATOR ",")'),
  9. 'quantities' => new Zend_Db_Expr('group_concat(`sales/order_item`.qty_ordered SEPARATOR ",")'),
  10. )
  11. );
  12. $collection->getSelect()->group('entity_id');
  13.  
  14. /* You will then need to add new columns in _prepareColumns() */
  15.  
  16. $this->addColumn('sku', array(
  17. 'header' => Mage::helper('Sales')->__('Skus'),
  18. 'width' => '100px',
  19. 'index' => 'skus',
  20. 'type' => 'text',
  21.  
  22. ));
  23. $this->addColumn('names', array(
  24. 'header' => Mage::helper('Sales')->__('Name'),
  25. 'width' => '100px',
  26. 'index' => 'names',
  27. 'type' => 'text',
  28. ));

URL: http://www.magentocommerce.com/boards/viewthread/218158/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.