cancel
Showing results for 
Search instead for 
Did you mean: 

Admin Sales Order Grid

Admin Sales Order Grid

Hello,

 

Does anyone know the correct way to add Shipping Date to the Admin Sales Order Grid, so I can see the date the order needs to be shipped, without going in to each individual order?

 

I've followed this here:

http://magento.stackexchange.com/questions/46444/how-to-add-shipped-date-to-admin-sales-order-grid?r...

 

app\code\local\Mage\Adminhtml\Block\Sales\Order\Grid.php I've added the following:

 

 

 protected function _prepareCollection()
    {
        $collection = Mage::getResourceModel($this->_getCollectionClass());
        $this->setCollection($collection);
        return parent::_prepareCollection();
		$collection->getSelect()->joinLeft('sales_flat_shipment_grid','sales_flat_shipment_grid.order_id=main_table.entity_id',array('shipped_date' => 'MAX(sales_flat_shipment_grid.created_at)'));
		$collection->getSelect()->group('main_table.entity_id');
return parent::_prepareCollection();
	
    }

 

and in protected function _prepareColumns() within app\code\local\Mage\Adminhtml\Block\Sales\Order\Grid.php  I've added the following:

$this->addColumn('shipped_date', array(
       'header'    => Mage::helper('sales')->__('Shipped Date'),
       'index'     => 'shipped_date',
       'type'      => 'datetime',
       'filter_index'=>'sales_flat_shipment_grid.created_at',
        ));

I'm getting an error when I implement it, but when I comment the following, I see the header filter but not reults in the individual orders listed on the page???

'index'     => 'shipped_date',

 I get the following error when implementing it without commenting out the above bit of code?

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'shipped_date' in 'where clause'

Trace:
#0 C:\xampp\htdocs\test_site\lib\Varien\Db\Statement\Pdo\Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 C:\xampp\htdocs\test_site\lib\Zend\Db\Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 C:\xampp\htdocs\test_site\lib\Zend\Db\Adapter\Abstract.php(479): Zend_Db_Statement->execute(Array)
#3 C:\xampp\htdocs\test_site\lib\Zend\Db\Adapter\Pdo\Abstract.php(238): Zend_Db_Adapter_Abstract->query('SELECT COUNT(*)...', Array)
#4 C:\xampp\htdocs\test_site\lib\Varien\Db\Adapter\Pdo\Mysql.php(419): Zend_Db_Adapter_Pdo_Abstract->query('SELECT COUNT(*)...', Array)
#5 C:\xampp\htdocs\test_site\lib\Zend\Db\Adapter\Abstract.php(825): Varien_Db_Adapter_Pdo_Mysql->query(Object(Varien_Db_Select), Array)
#6 C:\xampp\htdocs\test_site\lib\Varien\Data\Collection\Db.php(225): Zend_Db_Adapter_Abstract->fetchOne(Object(Varien_Db_Select), Array)
#7 C:\xampp\htdocs\test_site\lib\Varien\Data\Collection.php(225): Varien_Data_Collection_Db->getSize()
#8 C:\xampp\htdocs\test_site\lib\Varien\Data\Collection.php(211): Varien_Data_Collection->getLastPageNumber()
#9 C:\xampp\htdocs\test_site\lib\Varien\Data\Collection\Db.php(516): Varien_Data_Collection->getCurPage()
#10 C:\xampp\htdocs\test_site\lib\Varien\Data\Collection\Db.php(563): Varien_Data_Collection_Db->_renderLimit()
#11 C:\xampp\htdocs\test_site\app\code\core\Mage\Adminhtml\Block\Widget\Grid.php(533): Varien_Data_Collection_Db->load()
#12 C:\xampp\htdocs\test_site\app\code\local\Mage\Adminhtml\Block\Sales\Order\Grid.php(61): Mage_Adminhtml_Block_Widget_Grid->_prepareCollection()
#13 C:\xampp\htdocs\test_site\app\code\core\Mage\Adminhtml\Block\Widget\Grid.php(626): Mage_Adminhtml_Block_Sales_Order_Grid->_prepareCollection()
#14 C:\xampp\htdocs\test_site\app\code\core\Mage\Adminhtml\Block\Widget\Grid.php(632): Mage_Adminhtml_Block_Widget_Grid->_prepareGrid()
#15 C:\xampp\htdocs\test_site\app\code\core\Mage\Core\Block\Abstract.php(862): Mage_Adminhtml_Block_Widget_Grid->_beforeToHtml()
#16 C:\xampp\htdocs\test_site\app\code\core\Mage\Core\Block\Abstract.php(582): Mage_Core_Block_Abstract->toHtml()
#17 C:\xampp\htdocs\test_site\app\code\core\Mage\Core\Block\Abstract.php(526): Mage_Core_Block_Abstract->_getChildHtml('grid', true)
#18 C:\xampp\htdocs\test_site\app\code\core\Mage\Adminhtml\Block\Widget\Grid\Container.php(77): Mage_Core_Block_Abstract->getChildHtml('grid')
#19 C:\xampp\htdocs\test_site\app\design\adminhtml\default\default\template\widget\grid\container.phtml(36): Mage_Adminhtml_Block_Widget_Grid_Container->getGridHtml()
#20 C:\xampp\htdocs\test_site\app\code\core\Mage\Core\Block\Template.php(241): include('C:\\xampp\\htdocs...')
#21 C:\xampp\htdocs\test_site\app\code\core\Mage\Core\Block\Template.php(272): Mage_Core_Block_Template->fetchView('adminhtml\\defau...')
#22 C:\xampp\htdocs\test_site\app\code\core\Mage\Core\Block\Template.php(286): Mage_Core_Block_Template->renderView()
#23 C:\xampp\htdocs\test_site\app\code\core\Mage\Adminhtml\Block\Template.php(81): Mage_Core_Block_Template->_toHtml()
#24 C:\xampp\htdocs\test_site\app\code\core\Mage\Adminhtml\Block\Widget\Container.php(308): Mage_Adminhtml_Block_Template->_toHtml()
#25 C:\xampp\htdocs\test_site\app\code\core\Mage\Core\Block\Abstract.php(863): Mage_Adminhtml_Block_Widget_Container->_toHtml()
#26 C:\xampp\htdocs\test_site\app\code\core\Mage\Core\Block\Text\List.php(43): Mage_Core_Block_Abstract->toHtml()
#27 C:\xampp\htdocs\test_site\app\code\core\Mage\Core\Block\Abstract.php(863): Mage_Core_Block_Text_List->_toHtml()
#28 C:\xampp\htdocs\test_site\app\code\core\Mage\Core\Block\Abstract.php(582): Mage_Core_Block_Abstract->toHtml()
#29 C:\xampp\htdocs\test_site\app\code\core\Mage\Core\Block\Abstract.php(526): Mage_Core_Block_Abstract->_getChildHtml('content', true)
#30 C:\xampp\htdocs\test_site\app\design\adminhtml\default\default\template\page.phtml(74): Mage_Core_Block_Abstract->getChildHtml('content')
#31 C:\xampp\htdocs\test_site\app\code\core\Mage\Core\Block\Template.php(241): include('C:\\xampp\\htdocs...')
#32 C:\xampp\htdocs\test_site\app\code\core\Mage\Core\Block\Template.php(272): Mage_Core_Block_Template->fetchView('adminhtml\\defau...')
#33 C:\xampp\htdocs\test_site\app\code\core\Mage\Core\Block\Template.php(286): Mage_Core_Block_Template->renderView()
#34 C:\xampp\htdocs\test_site\app\code\core\Mage\Adminhtml\Block\Template.php(81): Mage_Core_Block_Template->_toHtml()
#35 C:\xampp\htdocs\test_site\app\code\core\Mage\Core\Block\Abstract.php(863): Mage_Adminhtml_Block_Template->_toHtml()
#36 C:\xampp\htdocs\test_site\app\code\core\Mage\Core\Model\Layout.php(555): Mage_Core_Block_Abstract->toHtml()
#37 C:\xampp\htdocs\test_site\app\code\core\Mage\Core\Controller\Varien\Action.php(390): Mage_Core_Model_Layout->getOutput()
#38 C:\xampp\htdocs\test_site\app\code\core\Mage\Adminhtml\controllers\Sales\OrderController.php(95): Mage_Core_Controller_Varien_Action->renderLayout()
#39 C:\xampp\htdocs\test_site\app\code\core\Mage\Core\Controller\Varien\Action.php(419): Mage_Adminhtml_Sales_OrderController->indexAction()
#40 C:\xampp\htdocs\test_site\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('index')
#41 C:\xampp\htdocs\test_site\app\code\core\Mage\Core\Controller\Varien\Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#42 C:\xampp\htdocs\test_site\app\code\core\Mage\Core\Model\App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#43 C:\xampp\htdocs\test_site\app\Mage.php(683): Mage_Core_Model_App->run(Array)
#44 C:\xampp\htdocs\test_site\index.php(90): Mage::run('', 'store')
#45 {main}

 Can someone help as I've search interweb with no joy :-( and it's beyond my skills to understand why it's failing...

Regards

 

Mal