/**
  * @inheritdoc
  */
 protected function _renderFiltersBefore()
 {
     $this->getSearchCriteriaBuilder();
     $this->getFilterBuilder();
     $this->getSearch();
     if ($this->queryText) {
         $this->filterBuilder->setField('search_term');
         $this->filterBuilder->setValue($this->queryText);
         $this->searchCriteriaBuilder->addFilter($this->filterBuilder->create());
     }
     $priceRangeCalculation = $this->_scopeConfig->getValue(\Magento\Catalog\Model\Layer\Filter\Dynamic\AlgorithmFactory::XML_PATH_RANGE_CALCULATION, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
     if ($priceRangeCalculation) {
         $this->filterBuilder->setField('price_dynamic_algorithm');
         $this->filterBuilder->setValue($priceRangeCalculation);
         $this->searchCriteriaBuilder->addFilter($this->filterBuilder->create());
     }
     $searchCriteria = $this->searchCriteriaBuilder->create();
     $searchCriteria->setRequestName($this->searchRequestName);
     $this->searchResult = $this->search->search($searchCriteria);
     $temporaryStorage = $this->temporaryStorageFactory->create();
     $table = $temporaryStorage->storeApiDocuments($this->searchResult->getItems());
     $this->getSelect()->joinInner(['search_result' => $table->getName()], 'e.entity_id = search_result.' . TemporaryStorage::FIELD_ENTITY_ID, []);
     $this->_totalRecords = $this->searchResult->getTotalCount();
     if ($this->order && 'relevance' === $this->order['field']) {
         $this->getSelect()->order('search_result.' . TemporaryStorage::FIELD_SCORE . ' ' . $this->order['dir']);
     }
     return parent::_renderFiltersBefore();
 }
 /**
  * Returns search criteria
  *
  * @return \Magento\Framework\Api\Search\SearchCriteria
  */
 public function getSearchCriteria()
 {
     if (!$this->searchCriteria) {
         $this->searchCriteria = $this->searchCriteriaBuilder->create();
         $this->searchCriteria->setRequestName($this->name);
     }
     return $this->searchCriteria;
 }
 /**
  * @inheritdoc
  */
 protected function _renderFiltersBefore()
 {
     if ($this->filters) {
         foreach ($this->filters as $attributes) {
             foreach ($attributes as $attributeCode => $attributeValue) {
                 $attributeCode = $this->getAttributeCode($attributeCode);
                 $this->addAttributeToSearch($attributeCode, $attributeValue);
             }
         }
         $searchCriteria = $this->searchCriteriaBuilder->create();
         $searchCriteria->setRequestName('advanced_search_container');
         $searchResult = $this->search->search($searchCriteria);
         $temporaryStorage = $this->temporaryStorageFactory->create();
         $table = $temporaryStorage->storeApiDocuments($searchResult->getItems());
         $this->getSelect()->joinInner(['search_result' => $table->getName()], 'e.entity_id = search_result.' . TemporaryStorage::FIELD_ENTITY_ID, []);
     }
     parent::_renderFiltersBefore();
 }
 /**
  * Add sales rules.
  */
 public function init()
 {
     $crit = $this->_builderSearchCriteria->create();
     $crit->setSortOrders(null);
     /** @var \Magento\Framework\Api\SearchResults $all */
     $all = $this->_repoRule->getList($crit);
     $total = $all->getTotalCount();
     if ($total) {
         /** @var \Magento\SalesRule\Model\Data\Rule $item */
         foreach ($all->getItems() as $item) {
             $this->_repoRule->deleteById($item->getRuleId());
         }
     }
     $this->_loadCustomerGroups();
     $desc = 'This rule is added by initialization script for test proposes.';
     $this->_createRuleBySku('10% off to Bee Royal', $desc, '212San', 10);
     $this->_createRuleBySku('20% off to BoostIron', $desc, '10674San', 20);
     $this->_createRuleForOrder('$20 off to cart subtotal above $100', $desc, 100, 20);
 }
예제 #5
0
 /**
  * @inheritdoc
  */
 protected function _renderFiltersBefore()
 {
     $this->getSearchCriteriaBuilder();
     $this->getFilterBuilder();
     $this->getSearch();
     if ($this->queryText) {
         $this->filterBuilder->setField('search_term');
         $this->filterBuilder->setValue($this->queryText);
         $this->searchCriteriaBuilder->addFilter($this->filterBuilder->create());
     }
     $priceRangeCalculation = $this->_scopeConfig->getValue(\Magento\Catalog\Model\Layer\Filter\Dynamic\AlgorithmFactory::XML_PATH_RANGE_CALCULATION, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
     if ($priceRangeCalculation) {
         $this->filterBuilder->setField('price_dynamic_algorithm');
         $this->filterBuilder->setValue($priceRangeCalculation);
         $this->searchCriteriaBuilder->addFilter($this->filterBuilder->create());
     }
     $searchCriteria = $this->searchCriteriaBuilder->create();
     $searchCriteria->setRequestName($this->searchRequestName);
     try {
         $this->searchResult = $this->getSearch()->search($searchCriteria);
     } catch (EmptyRequestDataException $e) {
         /** @var \Magento\Framework\Api\Search\SearchResultInterface $searchResult */
         $this->searchResult = $this->searchResultFactory->create()->setItems([]);
     } catch (NonExistingRequestNameException $e) {
         $this->_logger->error($e->getMessage());
         throw new LocalizedException(__('Sorry, something went wrong. You can find out more in the error log.'));
     }
     $temporaryStorage = $this->temporaryStorageFactory->create();
     $table = $temporaryStorage->storeApiDocuments($this->searchResult->getItems());
     $this->getSelect()->joinInner(['search_result' => $table->getName()], 'e.entity_id = search_result.' . TemporaryStorage::FIELD_ENTITY_ID, []);
     $this->_totalRecords = $this->searchResult->getTotalCount();
     if ($this->order && 'relevance' === $this->order['field']) {
         $this->getSelect()->order('search_result.' . TemporaryStorage::FIELD_SCORE . ' ' . $this->order['dir']);
     }
     return parent::_renderFiltersBefore();
 }