magentodev
magentodev

Reputation: 179

Magento 2 - Redirects search if only one result

I'm trying to custom the default Magento 2 search engine. I would like to automatically redirects to the product page when search returns only one result. I tried to override the Result/Index controller but nothings worked.

Thanks for your help !

Upvotes: 1

Views: 1667

Answers (2)

Aurélien FOUCRET
Aurélien FOUCRET

Reputation: 144

This is a native feature of ElasticSuite : https://github.com/Smile-SA/elasticsuite

Maybe should you give a try at the extension.

Disclosure : I am the lead developper of ElasticSuite

Upvotes: 1

Christophe Ferreboeuf
Christophe Ferreboeuf

Reputation: 1058

You need to use the configuration, no need to devellop anything additionnal. Here is a link to a good resource : https://www.magestore.com/magento-2-tutorial/how-to-manage-search-term-in-magento-2/

If you really need to redirect programmatically, I advise you to use dependency injection more than override.

Upvotes: 0

Related Questions