0

I am trying to add category filter in my admin product grid. which i have added successfully but i am facing problem while pagination, for that i need to implement custom filter string for product grid, please provide some clue for preparing custom filter string. I have even tried below to set Default filter

$cat_ids = array(17,18);

$this->setDefaultFilter(array('category_id' => $cat_ids));

1 Answer 1

2

You cannot use default filter (or any filter for that mater) unless you have the columns referenced in the filter in your grid. So if the Grid does not contain the column category_id then it won't work.

You might want to add this filter in _prepareCollection().

If your join needs a group by statement this will break the pagination, because ...well because that's how Magento works.

A workaround for this is described here. The post is about adding the category names to the product grid, but you can adapt it to work on _prepareCollection().

The main idea is to change the getSelectCountSql() method that is used for calculating the pagination to behave differently when you have a group by.

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.