DeliveryDate in Order Item Grid not sorting correctly

665 views Asked by At

I have created a sales order item grid in the admin panel in magento. The grid displays the Display Date correctly. However when I try to sort based on the delivery date it does not work. I include the delivery date as follows:

$this->addColumn('proptions', array(
        'header'    => Mage::helper('Sales')->__('Delivery Date'),
        'index'     => 'proptions',
        'renderer'  =>  new Bakery_Core_Block_Adminhtml_Renderer_Data(),
        'type'      => 'datetime',
    ));

In Renderer_Data I do the following:

$val = substr($_option['value'],0,10);  //returns format dd/MM/yyyy                    
                $val = str_replace("/","-",$val);  //returns dd-MM-yyyy
                $dateTimestamp = Mage::getModel('core/date')->timestamp(strtotime($val));
                $format_val = date('d M Y', $dateTimestamp);  // returns e.g. 13 Aug 2013

I have set the type in the grid for this column as datetime. However it still doesn't sort the date in the correct order. How can I fix this issue?

Thanks, Neet

1

There are 1 answers

3
Alvin Nguyen On

I checked the Grid in the Promo and it seems to use 'date' for 'type'

Example

    $this->addColumn('to_date', array(
        'header'    => Mage::helper('catalogrule')->__('Date Expire'),
        'align'     => 'left',
        'width'     => '120px',
        'type'      => 'date',
        'default'   => '--',
        'index'     => 'to_date',
    ));