I am trying to add a weight column to my magento order grid (I want the total weight of the order)
I have this part
_prepareColumns $this->addColumn('weight', array( 'header' => Mage::helper('sales')->__('Weight'), 'index' => 'weight', 'filter_index' => 'sfo.weight', 'width' => '50px', )); The column is shown, but no data is displayed
I think I need to add something in front of _prepareCollection();
Does anyone know the correct code for this?
below is the collection part i have already
protected function _getCollectionClass() { return 'sales/order_grid_collection'; } protected function _prepareCollection() { $collection = Mage::getResourceModel($this->_getCollectionClass()); $table = Mage::getSingleton('core/resource')->getTableName('sales_flat_shipment_grid'); //$collection->getSelect()->from('', "((select max(t.created_at) from `$table` as t where t.order_id=main_table.entity_id)) as shipped_date"); $collection ->getSelect() ->joinLeft(array('t'=>$table), 'main_table.entity_id = t.order_id',array('shipped_date'=>'created_at')) ->group('main_table.entity_id');; //file_put_contents(basename(__FILE__).".txt",__LINE__.":sql: ".$collection->getSelect()."\r\n",FILE_APPEND); $this->setCollection($collection); $collection->getSelect()->joinLeft(array('shipping'=>'sales_flat_order_address'), 'main_table.entity_id = shipping.parent_id AND shipping.address_type="shipping"',array('shipping.postcode AS sp')); return parent::_prepareCollection(); }