0

is there any need to override my custom observer.

I have an observer like:

\Vendor\Module\Observer\MyObserver.php

<?php
 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';
 $this->tglssearchEngineFactory->create()->getCatalogResult();
} 
*/
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
 echo 'obssrexe';
 $event = $observer->getEvent();
 $this->tglssearchEngineFactory->create()->getCatlogSearchResult();
}
 }

etc/frontend/events.xml

<?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"/> 
</event>
</config>

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

http://localhost:1338/magento2x_2/catalogsearch/result/?q=wirel

which i want it as

http://localhost:1338/magento2x_2/tgllsearch/result/?q=wirel

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

Should i have to override my Observer

asked Jul 8, 2016 at 11:55

1 Answer 1

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.

answered Jul 8, 2016 at 12:46

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.