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 );
    – allamgr
    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 );
    – allamgr
    Mar 15, 2017 at 13:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.