Beispiel #1
0
 /**
  * Get applied to layer filter items
  *
  * @return Item[]
  */
 public function getFilters()
 {
     try {
         if ($this->bxHelperData->isFilterLayoutEnabled($this->_layer)) {
             $category = $this->_categoryViewBlock->getCurrentCategory();
             if ($category != null && $category->getDisplayMode() == \Magento\Catalog\Model\Category::DM_PAGE) {
                 return parent::getFilters();
             }
             $filters = array();
             $facets = $this->p13nHelper->getFacets();
             if ($facets) {
                 foreach ($this->bxHelperData->getAllFacetFieldNames() as $fieldName) {
                     if ($facets->isSelected($fieldName)) {
                         $filter = $this->objectManager->create("Boxalino\\Intelligence\\Model\\LayerFilterItem");
                         $filter->setFacets($facets);
                         $filter->setFieldName($fieldName);
                         $filters[] = $filter;
                     }
                 }
             }
             return $filters;
         }
         return parent::getFilters();
     } catch (\Exception $e) {
         $this->bxHelperData->setFallback(true);
         $this->_logger->critical($e);
         return parent::getFilters();
     }
 }
Beispiel #2
0
 public function testGetIdentities()
 {
     $categoryTag = ['catalog_category_1'];
     $currentCatogoryMock = $this->getMock('Magento\\Catalog\\Model\\Category', [], [], '', false);
     $currentCatogoryMock->expects($this->once())->method('getIdentities')->will($this->returnValue($categoryTag));
     $this->block->setCurrentCategory($currentCatogoryMock);
     $this->assertEquals($categoryTag, $this->block->getIdentities());
 }
 /**
  * @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();
     }
 }