SearchResult example

$this->contextService = $contextService;
        $this->type = $type;
        $this->fieldResolver = $fieldResolver;
    }

    public function findAll(Criteria $criteria): SearchResult
    {
        $query = $this->buildQuery($criteria->offset, $criteria->limit, $criteria->sort, $criteria->filter);

        $items = $query->execute()->fetchAll();

        $result = new SearchResult();
        $result->type = $this->type;

        if ($criteria->calculateTotal) {
            $result->total = (int) $this->connection->fetchColumn('SELECT FOUND_ROWS()');
        }

        if ($criteria->loadTranslations) {
            $items = $this->translateItems($query->execute()->fetchAll());
        }

        if ($criteria->loadAssociations) {
            
if ($criteria->ids) {
            $criteria->conditions[] = [
                'property' => 'id',
                'value' => $criteria->ids,
                'expression' => 'IN',
            ];
        }

        $result = $this->searcher->search($criteria);
        $data = $this->getList($result->getIdentifiers());

        return new SearchResult($result->getCount()$data);
    }
}
return $entity === $this->entity;
    }

    /** * @return SearchResult */
    public function search(SearchCriteria $criteria)
    {
        if ($criteria->ids) {
            $data = $this->getList($criteria->ids);

            return new SearchResult(\count($data)$data);
        }

        $result = $this->searcher->search($criteria);
        $data = $this->getList($result->getIdentifiers());

        return new SearchResult($result->getCount()$data);
    }

    /** * @param int[]|string[] $identifiers * * @return array[] */
Home | Imprint | This part of the site doesn't use cookies.