Exemplo n.º 1
0
 /**
  * @return int|mixed
  */
 public function hasSubPhrases()
 {
     if ($this->bxHelperData->isSearchEnabled()) {
         if ($this->subPhrases == null) {
             $this->subPhrases = $this->p13Helper->areThereSubPhrases();
         }
         return $this->subPhrases;
     }
     return false;
 }
Exemplo n.º 2
0
 /**
  * @return AbstractCollection|mixed
  */
 public function _getProductCollection()
 {
     try {
         $layer = $this->getLayer();
         if ($this->bxHelperData->isFilterLayoutEnabled($layer)) {
             if (count($this->_productCollection) && !$this->p13nHelper->areThereSubPhrases()) {
                 return $this->_productCollection;
             }
             if ($layer instanceof \Magento\Catalog\Model\Layer\Category) {
                 if ($this->categoryViewBlock->isContentMode()) {
                     return parent::_getProductCollection();
                 }
             }
             if ($this->p13nHelper->areThereSubPhrases()) {
                 $this->queries = $this->p13nHelper->getSubPhrasesQueries();
                 $entity_ids = $this->p13nHelper->getSubPhraseEntitiesIds($this->queries[self::$number]);
                 $entity_ids = array_slice($entity_ids, 0, $this->bxHelperData->getSubPhrasesLimit());
             } else {
                 $entity_ids = $this->p13nHelper->getEntitiesIds();
             }
             if (count($entity_ids) == 0) {
                 $entity_ids = array(0);
             }
             $this->_setupCollection($entity_ids);
             return $this->_productCollection;
         } else {
             return parent::_getProductCollection();
         }
     } catch (\Exception $e) {
         $this->bxHelperData->setFallback(true);
         $this->_logger->critical($e);
         return parent::_getProductCollection();
     }
 }
Exemplo n.º 3
0
 /**
  * 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();
     }
 }
Exemplo n.º 4
0
 /**
  * @return int|mixed
  */
 public function hasSubPhrases()
 {
     if ($this->fallback) {
         return 0;
     }
     try {
         if ($this->bxHelperData->isSearchEnabled()) {
             if ($this->subPhrases == null) {
                 $this->subPhrases = $this->p13nHelper->areThereSubPhrases();
             }
             return $this->subPhrases;
         }
     } catch (\Exception $e) {
         $this->fallback = true;
         $this->_logger->critical($e);
     }
     return 0;
 }