we have a grid where we add a button. It triggers the shownewonlyAction in the controlller. But I have no idea how to set a filter (or even reset all filters) in the controller shownewonlyAction ().

question: How do I set a filter in the controller action? (something like state=processing) or preorder_status IS NULL


    $this->_addButton('shownewonly', array(
        'label'   => Mage::helper('catalog')->__('Show new only'),
        'onclick' => "setLocation('{$this->getUrl('*/*/shownewonly')}')",
        'class'   => 'index'

this is what I have tried

    public function shownewonlyAction()
    //$this->setDefaultFilter(array('preorder_status' => null));
    //$data = $this->prepareFilterString('pp.preorder_status IS NULL');
    //$filter = base64_encode('preorder_status=');
    //Mage::app()->getFrontController()->getRequest()->setParam('filter', $filter);

enter image description here

1 Answer 1


To do this you need to store the filter in the registry or session in the controller file and get it again in the grid.

Something like this in the controller file


and access this value in the function _prepareCollection() in the grid file

$filter = Mage::getSingleton("admin/session")->getFilter();
        if (!empty($filter)) { 
            foreach ($filter as $key => $value) {

I don't think there is another way

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.