public function getList(SearchCriteriaInterface $searchCriteria)
    {
        /** @var \Limesharp\Stockists\Api\Data\StockistSearchResultsInterface $searchResults */
        $searchResults = $this->searchResultsFactory->create();
        $searchResults->setSearchCriteria($searchCriteria);

        /** @var \Limesharp\Stockists\Model\ResourceModel\Stores\Collection $collection */
        $collection = $this->stockistCollectionFactory->create();

        //Add filters from root filter group to the collection
        /** @var FilterGroup $group */
        foreach ($searchCriteria->getFilterGroups() as $group) {
            $this->addFilterGroupToCollection($group, $collection);
        }
        $sortOrders = $searchCriteria->getSortOrders();
        /** @var SortOrder $sortOrder */
        if ($sortOrders) {
            foreach ($searchCriteria->getSortOrders() as $sortOrder) {
                $field = $sortOrder->getField();
                $collection->addOrder(
                    $field,
                    ($sortOrder->getDirection() == SortOrder::SORT_ASC) ? 'ASC' : 'DESC'
                );
            }
        } else {
            // set a default sorting order since this method is used constantly in many
            // different blocks
            $field = 'stockist_id';
            $collection->addOrder($field, 'ASC');
        }
        $collection->setCurPage($searchCriteria->getCurrentPage());
        $collection->setPageSize($searchCriteria->getPageSize());

        /** @var \Limesharp\Stockists\Api\Data\StockistInterface[] $stockists */
        $stockists = [];
        /** @var \Limesharp\Stockists\Model\Stores $stockist */
        foreach ($collection as $stockist) {
            /** @var \Limesharp\Stockists\Api\Data\StockistInterface $stockistDataObject */
            $stockistDataObject = $this->stockistInterfaceFactory->create();
            $this->dataObjectHelper->populateWithArray($stockistDataObject, $stockist->getData(), StockistInterface::class);
            $stockists[] = $stockistDataObject;
        }
        $searchResults->setTotalCount($collection->getSize());
        return $searchResults->setItems($stockists);
    }
public function getList(SearchCriteriaInterface $searchCriteria)
    {
        /** @var \Limesharp\Stockists\Api\Data\StockistSearchResultsInterface $searchResults */
        $searchResults = $this->searchResultsFactory->create();
        $searchResults->setSearchCriteria($searchCriteria);

        /** @var \Limesharp\Stockists\Model\ResourceModel\Stores\Collection $collection */
        $collection = $this->stockistCollectionFactory->create();

        //Add filters from root filter group to the collection
        /** @var FilterGroup $group */
        foreach ($searchCriteria->getFilterGroups() as $group) {
            $this->addFilterGroupToCollection($group, $collection);
        }
        $sortOrders = $searchCriteria->getSortOrders();
        /** @var SortOrder $sortOrder */
        if ($sortOrders) {
            foreach ($searchCriteria->getSortOrders() as $sortOrder) {
                $field = $sortOrder->getField();
                $collection->addOrder(
                    $field,
                    ($sortOrder->getDirection() == SortOrder::SORT_ASC) ? 'ASC' : 'DESC'
                );
            }
        } else {
            // set a default sorting order since this method is used constantly in many
            // different blocks
            $field = 'stockist_id';
            $collection->addOrder($field, 'ASC');
        }
        $collection->setCurPage($searchCriteria->getCurrentPage());
        $collection->setPageSize($searchCriteria->getPageSize());

        /** @var \Limesharp\Stockists\Api\Data\StockistInterface[] $stockists */
        $stockists = [];
        /** @var \Limesharp\Stockists\Model\Stores $stockist */
        foreach ($collection as $stockist) {
            /** @var \Limesharp\Stockists\Api\Data\StockistInterface $stockistDataObject */
            $stockistDataObject = $this->stockistInterfaceFactory->create();
            $this->dataObjectHelper->populateWithArray($stockistDataObject, $stockist->getData(), StockistInterface::class);
            $stockists[] = $stockistDataObject;
        }
        $searchResults->setTotalCount($collection->getSize());
        return $searchResults->setItems($stockists);
    }
public function getList ( SearchCriteriaInterface $ searchCriteria ) { /** @var \Limesharp\Stockists\Api\Data\StockistSearchResultsInterface $searchResults */ $ searchResults = $ this -> searchResultsFactory -> create ( ) ; $ searchResults -> setSearchCriteria ( $ searchCriteria ) ; /** @var \Limesharp\Stockists\Model\ResourceModel\Stores\Collection $collection */ $ collection = $ this -> stockistCollectionFactory -> create ( ) ; //Add filters from root filter group to the collection /** @var FilterGroup $group */ foreach ( $ searchCriteria -> getFilterGroups ( ) as $ group ) { $ this -> addFilterGroupToCollection ( $ group , $ collection ) ; } $ sortOrders = $ searchCriteria -> getSortOrders ( ) ; /** @var SortOrder $sortOrder */ if ( $ sortOrders ) { foreach ( $ searchCriteria -> getSortOrders ( ) as $ sortOrder ) { $ field = $ sortOrder -> getField ( ) ; $ collection -> addOrder ( $ field , ( $ sortOrder -> getDirection ( ) == SortOrder :: SORT_ASC ) ? 'ASC' : 'DESC' ) ; } } else { // set a default sorting order since this method is used constantly in many // different blocks $ field = 'stockist_id' ; $ collection -> addOrder ( $ field , 'ASC' ) ; } $ collection -> setCurPage ( $ searchCriteria -> getCurrentPage ( ) ) ; $ collection -> setPageSize ( $ searchCriteria -> getPageSize ( ) ) ; /** @var \Limesharp\Stockists\Api\Data\StockistInterface[] $stockists */ $ stockists = [ ] ; /** @var \Limesharp\Stockists\Model\Stores $stockist */ foreach ( $ collection as $ stockist ) { /** @var \Limesharp\Stockists\Api\Data\StockistInterface $stockistDataObject */ $ stockistDataObject = $ this -> stockistInterfaceFactory -> create ( ) ; $ this -> dataObjectHelper -> populateWithArray ( $ stockistDataObject , $ stockist -> getData ( ) , StockistInterface :: class ) ; $ stockists [ ] = $ stockistDataObject ; } $ searchResults -> setTotalCount ( $ collection -> getSize ( ) ) ; return $ searchResults -> setItems ( $ stockists ) ; }
Retrieve pages matching the specified criteria.

@param SearchCriteriaInterface $searchCriteria
@return \Limesharp\Stockists\Api\Data\StockistSearchResultsInterface
@throws \Magento\Framework\Exception\LocalizedException
Retrieve pages matching the specified criteria .