示例#1
0
 /**
  * @param string $method
  * @param string $value
  * @param string $expectedClass
  * @dataProvider getFiltersDataProvider
  *
  * @covers \Magento\Catalog\Model\Layer\FilterList::getFilters
  * @covers \Magento\Catalog\Model\Layer\FilterList::createAttributeFilter
  * @covers \Magento\Catalog\Model\Layer\FilterList::__construct
  */
 public function testGetFilters($method, $value, $expectedClass)
 {
     $this->objectManagerMock->expects($this->at(0))->method('create')->will($this->returnValue('filter'));
     $this->objectManagerMock->expects($this->at(1))->method('create')->with($expectedClass, array('data' => array('attribute_model' => $this->attributeMock), 'layer' => $this->layerMock))->will($this->returnValue('filter'));
     $this->attributeMock->expects($this->once())->method($method)->will($this->returnValue($value));
     $this->attributeListMock->expects($this->once())->method('getList')->will($this->returnValue(array($this->attributeMock)));
     $this->assertEquals(array('filter', 'filter'), $this->model->getFilters($this->layerMock));
 }
 public function getFilters(Layer $layer)
 {
     if (!$this->helper->isActiveEngine()) {
         return parent::getFilters($layer);
     }
     if (!count($this->filters)) {
         $this->filters = [];
         // $response = $this->_getResponse($layer);
         $response = $this->searchHelper->getCustomResults();
         $questions = $response->QwiserSearchResults->Questions;
         $aaa = '';
         foreach ($questions->children() as $question) {
             $this->filters[] = $this->createQuestionFilter($question, $layer);
             $this->appliedFilters[] = $question->getAttribute('Text');
         }
     }
     $remFilters = array_diff($this->searchHelper->getFilterRequestVars(), $this->appliedFilters);
     foreach ($this->request->getParams() as $var => $value) {
         if (in_array($var, $remFilters)) {
             $question = $this->searchHelper->getQuestionByField($var, 'Text');
             if ($question) {
                 $this->createQuestionFilter($question, $layer)->apply($this->request);
                 $this->appliedFilters[] = $var;
             }
         }
     }
     return $this->filters;
 }
示例#3
0
 /**
  * @param \Magento\Catalog\Model\Layer $layer
  * @return array|\Magento\Catalog\Model\Layer\Filter\AbstractFilter[]
  */
 public function getFilters(\Magento\Catalog\Model\Layer $layer)
 {
     try {
         if ($this->bxHelperData->isFilterLayoutEnabled($layer) && $this->bxHelperData->isLeftFilterEnabled()) {
             $filters = array();
             $facets = $this->getBxFacets();
             if ($facets) {
                 foreach ($this->bxHelperData->getLeftFacetFieldNames() as $fieldName) {
                     $attribute = $this->objectManager->create("Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute");
                     $filter = $this->objectManager->create("Boxalino\\Intelligence\\Model\\Attribute", ['data' => ['attribute_model' => $attribute], 'layer' => $layer]);
                     $filter->setFacets($facets);
                     $filter->setFieldName($fieldName);
                     $filters[] = $filter;
                 }
             }
             return $filters;
         } else {
             return parent::getFilters($layer);
         }
     } catch (\Exception $e) {
         $this->bxHelperData->setFallback(true);
         $this->_logger->critical($e);
         return parent::getFilters($layer);
     }
 }
示例#4
0
 /**
  * {@inheritDoc}
  */
 protected function getAttributeFilterClass(\Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute)
 {
     $filterClassName = parent::getAttributeFilterClass($attribute);
     if ($attribute->getBackendType() == 'varchar' && $attribute->getFrontendClass() == 'validate-number') {
         $filterClassName = $this->filterTypes[self::DECIMAL_FILTER];
     }
     if ($attribute->getFrontendInput() == 'boolean' && $attribute->getSourceModel() == 'Magento\\Eav\\Model\\Entity\\Attribute\\Source\\Boolean' && isset($this->filterTypes[self::BOOLEAN_FILTER])) {
         $filterClassName = $this->filterTypes[self::BOOLEAN_FILTER];
     }
     return $filterClassName;
 }
示例#5
0
 /**
  * Get all layer filters
  *
  * @return array
  */
 public function getFilters()
 {
     return $this->filterList->getFilters($this->_catalogLayer);
 }