REGE Posted January 21, 2024 Share Posted January 21, 2024 (edited) I am creating a module, I want to change `id_product` filter for the admin product grid from IntegerMinMaxFilterType to TextType. I managed to do it using hookActionProductGridDefinitionModifier: public function hookActionProductGridDefinitionModifier(array $params) { if (empty($params['definition'])) return; /** @var PrestaShop\PrestaShop\Core\Grid\Definition\GridDefinitionInterface $definition */ $definition = $params['definition']; $filters = $definition->getFilters(); $filters ->remove('id_product') ->add( (new Filter('id_product', TextType::class)) ->setTypeOptions([ 'required' => false, ]) ->setAssociatedColumn('id_product') ) ; } The filter field has changed, but after entering a value in it and clicking "Search", I get an error: Quote PrestaShop\PrestaShop\Core\Grid\Query\Filter\DoctrineFilterApplicator::computeMinMaxCase(): Argument #1 ($value) must be of type array, string given, called in /src/Core/Grid/Query/Filter/DoctrineFilterApplicator.php on line 93 Can you tell me what else I should change and where? Edited January 21, 2024 by REGE (see edit history) Link to comment Share on other sites More sharing options...
ps8modules Posted January 21, 2024 Share Posted January 21, 2024 (edited) hi. For this to be valid, you also need to have an override twig template. /src/PrestaShopBundle/Resources/views/Admin/Product/CatalogPage/Lists/products_table.html.twig Old: Sample: <td> <input type="text" class="form-control" placeholder="{{ "Search ID."|trans({}, 'Admin.Catalog.Help') }}" name="filter_column_id_product" value="{{ filter_column_id_product }}" aria-label="{{ "%inputId% input"|trans({'%inputId%': 'filter_column_id_product'}, 'Admin.Global') }}" {% if filters_disabled %}disabled{% endif %} /> </td> And ./src/Adapter/Product/AdminProductDataProvider.php Edited January 21, 2024 by ps8moduly.cz (see edit history) Link to comment Share on other sites More sharing options...
REGE Posted January 24, 2024 Author Share Posted January 24, 2024 Thank you very much for your answer, I was hoping to avoid overwriting the twig template and dataprovider. I give up changing the filter type for now. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now