0

Why does my search engine not navigate or call my custom controller when i have overriden my default Magento search engine.

When i search for a product keyword, it redirects to core

localhost:1338/magento2x_2/catalogsearch/result/?q=keyword

But i want it as:

localhost:1338/magento2x_2/tglssearch/result/?q=keyword

I have overridden Catalogsearch in etc di as:

 <preference for="Magento\CatalogSearch\Controller\Result\Index" type="Company\Module\Controller\Result\Index" />

My frontend routes:

<?xml version="1.0"?>
  <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
    <route id="tglssearch" frontName="tglssearch">
        <module name="Vendor_Module"/>
    </route>
</router>
 </config>
0

Sachin S,

preference tag<preference></preference> rewrite a class. It does not override frontname of a module.

So you need to change

tglssearch/result/?q=keyword

to

catalogsearch/result/?q=keyword

Also does not need route.xml as you have using same route

| improve this answer | |
  • I have not manually added "tglssearch/result/?q=keyword" but what i want is when i search for a key, the url should redirect to my custom front name 'tgllsearch/result', instead of the core catalogsearch/result...is that not possible...??? – Sushivam Jul 12 '16 at 7:58
  • I really need this fix... @Amit i m finding ways to fix this from more than a week... after overriding my custom controller and phtml template, when i search for a keyword, my page goes blank... could you please check and help on this link magento.stackexchange.com/questions/122625/… – Sushivam Jul 12 '16 at 8:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.