0

In magento2 I want to change the catalog search query of the frontend.

In particular, when there are multiple words in search query I would search with AND instead of OR. Example "red apple" not "red" and "apple".

Which file should I change?

1

You can find the execute function at

/vendor/magento/module-search/Controller/Ajax/Suggest.php


public function execute()
{
    if (!$this->getRequest()->getParam('q', false)) {
        /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
        $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
        $resultRedirect->setUrl($this->_url->getBaseUrl());
        return $resultRedirect;
    }

You can modify the query by your module Ref

Hope this helps.

| improve this answer | |

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.