I need to modify standart Magento search to remove some symbols and some additional logic. My code looks something like this:
public function execute()
{
$query = $this->_queryFactory->get();
$queryText = $query->getQueryText();
$manufacturer = false;
$pos = strrpos($queryText, "-");
if ($pos >= 0) {
$queryText = str_replace("-", "", $queryText);
$query->setQueryText($queryText);
}
if (strlen($queryText) == 17) { //if search string like a VIN code
$queryText = strtoupper($queryText);
$wmi = substr($queryText, 0, 3);
$manufacturer = $this->_getManufacturer($wmi); //get car manufacturer from VIN
if ($manufacturer) {
//redirect to parts catalog for car VIN code
$resultRedirect = $this->resultRedirectFactory->create();
$redirectLink = "/my/internal/controller/$manufacturer/?vin=$queryText";
$resultRedirect->setUrl($redirectLink);
return $resultRedirect;
}
}
This worked fine until version 2.7.x but not now. Can anyone tell me what’s changed in the latest versions of Magento 2? And how can I customize my search now?