/**
  * @param SearchCriteriaInterface $searchCriteria
  * @return SearchResultInterface
  */
 public function search(SearchCriteriaInterface $searchCriteria)
 {
     $collection = $this->collectionFactory->getReport($searchCriteria->getRequestName());
     $collection->setPageSize($searchCriteria->getPageSize());
     $collection->setCurPage($searchCriteria->getCurrentPage());
     $this->filterPool->applyFilters($collection, $searchCriteria);
     foreach ($searchCriteria->getSortOrders() as $sortOrder) {
         if ($sortOrder->getField()) {
             $collection->setOrder($sortOrder->getField(), $sortOrder->getDirection());
         }
     }
     return $collection;
 }
Exemple #2
0
 /**
  * {@inheritdoc}
  */
 public function search(SearchCriteriaInterface $searchCriteria)
 {
     $this->requestBuilder->setRequestName($searchCriteria->getRequestName());
     $scope = $this->scopeResolver->getScope();
     $this->requestBuilder->bindDimension('scope', $scope);
     foreach ($searchCriteria->getFilterGroups() as $filterGroup) {
         foreach ($filterGroup->getFilters() as $filter) {
             $this->addFieldToFilter($filter->getField(), $filter->getValue());
         }
     }
     $this->requestBuilder->setFrom($searchCriteria->getCurrentPage() * $searchCriteria->getPageSize());
     $this->requestBuilder->setSize($searchCriteria->getPageSize());
     $request = $this->requestBuilder->create();
     $searchResponse = $this->searchEngine->search($request);
     return $this->searchResponseBuilder->build($searchResponse)->setSearchCriteria($searchCriteria);
 }