/**
  * @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;
 }
Example #2
0
 /**
  * Apply various selection filters to prepare the sales order grid collection.
  *
  * @return $this
  */
 protected function _prepareCollection()
 {
     $billingAgreement = $this->coreRegistry->registry('current_billing_agreement');
     if ($billingAgreement) {
         $collection = $this->collectionFactory->getReport('sales_order_grid_data_source')->addFieldToSelect('entity_id')->addFieldToSelect('increment_id')->addFieldToSelect('customer_id')->addFieldToSelect('created_at')->addFieldToSelect('grand_total')->addFieldToSelect('order_currency_code')->addFieldToSelect('store_id')->addFieldToSelect('billing_name')->addFieldToSelect('shipping_name');
         $this->billingAgreementResource->addOrdersFilter($collection, $billingAgreement->getId());
         $this->setCollection($collection);
     }
     return parent::_prepareCollection();
 }