38 private $_queryFactory;
45 private $layerResolver;
61 parent::__construct($context);
63 $this->_catalogSession = $catalogSession;
64 $this->_queryFactory = $queryFactory;
65 $this->layerResolver = $layerResolver;
80 $query = $this->_queryFactory->get();
82 $storeId = $this->_storeManager->getStore()->getId();
85 $queryText =
$query->getQueryText();
87 if ($queryText !=
'') {
88 $catalogSearchHelper = $this->_objectManager->get(\
Magento\CatalogSearch\Helper\Data::class);
90 $getAdditionalRequestParameters = $this->
getRequest()->getParams();
93 if (empty($getAdditionalRequestParameters) &&
94 $this->_objectManager->get(PopularSearchTerms::class)->isCacheable($queryText,
$storeId)
96 $this->getCacheableResult($catalogSearchHelper,
$query);
98 $this->getNotCacheableResult($catalogSearchHelper,
$query);
112 private function getCacheableResult($catalogSearchHelper,
$query)
114 if (!$catalogSearchHelper->isMinQueryLength()) {
115 $redirect =
$query->getRedirect();
116 if ($redirect && $this->_url->getCurrentUrl() !== $redirect) {
122 $catalogSearchHelper->checkNotes();
124 $this->_view->loadLayout();
125 $this->_view->renderLayout();
137 private function getNotCacheableResult($catalogSearchHelper,
$query)
139 if ($catalogSearchHelper->isMinQueryLength()) {
140 $query->setId(0)->setIsActive(1)->setIsProcessed(1);
142 $query->saveIncrementalPopularity();
143 $redirect =
$query->getRedirect();
144 if ($redirect && $this->_url->getCurrentUrl() !== $redirect) {
150 $catalogSearchHelper->checkNotes();
152 $this->_view->loadLayout();
154 $this->_view->renderLayout();
_redirect($path, $arguments=[])
__construct(Context $context, Session $catalogSession, StoreManagerInterface $storeManager, QueryFactory $queryFactory, Resolver $layerResolver)
const CATALOG_LAYER_SEARCH