Posted By

ddavidd on 03/30/12


Tagged

php magento 161


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

WGenie


Add a SKU column to the order grid in Magento 1.6.1


 / Published in: PHP
 

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

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

  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. ));

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: neilspinney on May 16, 2012

Hi could you give some more info or supply the full grid.php with your code added as when I insert as your instructions I get errors. I am running Magento 1.6.2.0

You need to login to post a comment.