is there any need to override my custom observer.

I have an observer like:


 namespace Vendor\Module\Observer;
 use \Magento\Framework\Event\Observer;
 use Magento\Framework\Event\ObserverInterface;

 class MyObserver implements ObserverInterface

 * @var \Vendor\Module\Model\EngineFactory
protected $tglssearchEngineFactory;

public function __construct(
    \Vendor\Module\Model\Engine $tglssearchEngineFactory

) {
    $this->tglssearchEngineFactory = $tglssearchEngineFactory;


  /*  public function createSearchObject(\Magento\Framework\Event\Observer $observer)
    echo 'obssr';

  public function execute(\Magento\Framework\Event\Observer $observer)
    echo 'obssrexe';
    $event = $observer->getEvent();



<?xml version="1.0"?>
 <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
 <event name="controller_action_predispatch_catalogsearch_result_index">
    <observer name="controller_action_predispatch_catalogsearch_result_handler" instance="vendor\Module\Observer\MyObserver"/> 

Is my event name correct?

My router frontname: tgllsearch

Controller name: result

Action: index

Now in my home page, when i try to search for a keyword for a product, the url gets redirected to


which i want it as


But from : catalogsearch/result/?q=wirel my echo obssrexe is printing.

Should i have to override my Observer

1 Answer 1


I think you need to rewrite controller of Magento_CatalogSearch and not the Observer.

Take a look at this topic : https://magento.stackexchange.com/a/122774/6643.

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.