4

I want to have a default value in a column on sales grid, the value will be the actual day.

$this->addColumn('created_at', array( 'header' => Mage::helper('sales')->__('Purchased On'), 'index' => 'created_at', 'type' => 'datetime', 'width' => '100px', 'filter_index' => 'main_table.created_at', 'value'=>array( 'from'=>date('Y-m-d', time()) ) )); 

But its not working and I don't know why.

How can I do that?

3 Answers 3

1

try below code

$this->addColumn('created_at', array( 'header' => Mage::helper('sales')->__('Purchased On'), 'index' => 'created_at', 'type' => 'datetime', 'width' => '100px', 'filter_index' => 'main_table.created_at', 'value'=>array( 'from'=>date('Y-m-d') ) )); 
1
  • 2
    That is exactly what I have, but I solved with the method $this->setDefaultFilter( $arrayFilter ); Commented Mar 15, 2017 at 13:28
2

In the _prepareColumns method of my custom class extending Mage_Adminhtml_Block_Catalog_Product_Grid I was able to set a filter like this:

$this->setDefaultFilter(array('status' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED)); 

or

$this->setDefaultFilter(array('name' => 'foo')); 
0

File Path:

app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php

Put your code these way You can See Only actual day

 $this->addColumn('created_at', array( 'header' => Mage::helper('sales')->__('Purchased On'), 'index' => 'created_at', 'type' => 'date', 'width' => '100px', )); 
1
  • 2
    That is exactly what I have, but I solved with the method $this->setDefaultFilter( $arrayFilter ); Commented Mar 15, 2017 at 13:28

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.