/** * Display search result * * @return void */ public function execute() { if ($this->bxHelperData->isSearchEnabled()) { $this->layerResolver->create(Resolver::CATALOG_LAYER_SEARCH); /* @var $query \Magento\Search\Model\Query */ $query = $this->_queryFactory->get(); try { if ($this->p13Helper->areThereSubPhrases()) { $queries = $this->p13Helper->getSubPhrasesQueries(); if (count($queries) == 1) { $this->_redirect('*/*/*', array('_current' => true, '_query' => array('q' => $queries[0]))); } } if ($this->p13Helper->areResultsCorrected()) { $correctedQuery = $this->p13Helper->getCorrectedQuery(); $query->setQueryText($correctedQuery); } } catch (\Exception $e) { $this->bxHelperData->setFallback(true); $this->_logger->critical($e); } $query->setStoreId($this->_storeManager->getStore()->getId()); if ($query->getQueryText() != '') { if ($this->_objectManager->get('Magento\\CatalogSearch\\Helper\\Data')->isMinQueryLength()) { $query->setId(0)->setIsActive(1)->setIsProcessed(1); } else { $query->saveIncrementalPopularity(); if ($query->getRedirect()) { $this->getResponse()->setRedirect($query->getRedirect()); return; } } $this->_objectManager->get('Magento\\CatalogSearch\\Helper\\Data')->checkNotes(); $this->_view->loadLayout(); $this->_view->renderLayout(); } else { $this->getResponse()->setRedirect($this->_redirect->getRedirectUrl()); } } else { parent::execute(); } }
/** * @return \Magento\Framework\Phrase|string */ public function getSearchQueryText() { if ($this->fallback) { return parent::getSearchQueryText(); } if ($this->bxHelperData->isSearchEnabled() && $this->p13nHelper->areResultsCorrected()) { $correctedQuery = $this->p13nHelper->getCorrectedQuery(); return __("Corrected search results for: '%1'", $correctedQuery); } else { if ($this->hasSubPhrases()) { return ""; } else { return parent::getSearchQueryText(); } } }