Closed sarjon closed 4 years ago
Hello @sarjon, I share most of the issues you describe here but we have to stick with how search is stored actually.
But, I like your implementation with a specific key, and add a new column called identifier to AdminFilter entity.
Let me think about it :)
Ping @Quetzacoalt91, is it ok to add a new column to admin_filter table?
Of course, just handle it for the upgrades too.
How it currently works
Let's say we have action that lists products:
Currently filters are injected into action by using controller's & action's name (in this case
Product
andlisting
) which are used to find them in database. And it works.Use cases
1. Exporting filtered data
Now I want to use same filters to export products, so I create new action:
And it does not work anymore as filters cannot be found by combination of controller
Product
and actionexport
, so default values get injected.2. Multiple listings (grids) in the same page:
Imagine I want to render 2 or more listings in same action, what I would like to do is:
And this wouldn't work as well, same reason as in 1st use case.
Possible improvement
What if we update abstract class
PrestaShop\PrestaShop\Core\Search\Filters
with new methods like:This of course would work as you wont have to parse controller and action name from request, but it would be confusing as it can be used in other controllers and actions than it is configured in filters.
Another solution could be to define some unique key:
And implemented like:
In this case we could define key in
controller_action
format so it is compatible with current implementation.