4

I have created a custom grid and collection. Now, I am saving the filters to session for future use using:

$this->setSaveParametersInSession(true);

and retrieving this in another controller. How am I going to apply these parameters upon loading the collection?

I can retrieve the parameters/filters using:

$filters = Mage::getSingleton('adminhtml/session')->getData('custom_block_gridfilter');
$filters = Mage::helper('adminhtml')->prepareFilterString($filters);

Now, how am I going to apply it to?

Mage::getModel('custom/model')->getCollection();

Or perhaps how am I going to retrieve the grid collection with the filters applied to it?

1 Answer 1

1

Theoretically \Mage_Adminhtml_Block_Widget_Grid::_prepareCollection should take care of this.

So if you have overwritten this method, maybe the problem is only, that you don't call parent::_prepareCollection

3
  • So this isn't possible to be retrieved using some custom model that doesn't inherit Mage_Adminhtml_Block_Widget_Grid? Commented Nov 18, 2015 at 23:04
  • Why would one do that?! :D And to answer the question: Sure it is doable. At least by copying all the code... Commented Nov 18, 2015 at 23:07
  • 1
    Assuming you have millions of items in a collection, then in a custom grid which has been filtered already into a smaller set, then you have another page let's say mass edit for the items that have been filtered/selected, then you might wanna retrieve those items to some other custom controller/model. Commented Nov 19, 2015 at 2:19

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.