Navigation
eZ Documentation Center
 

This is outdated documentation made for eZ Publish Platform 5.2. It is being moved into the eZ Publish 5.x documentation, so please go there for most up-to-date documentation.

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagephp
$result = $searchService->findContent( $query );
$output->writeln( 'Found ' . $result->totalCount . ' items' );
foreach ( $result->searchHits as $searchHit )
{
    $output->writeln( $searchHit->valueObject->contentInfo->name );
}

The The searchHits properties  properties of the the SearchResult object  object is an array of ContentInfo objects SearchHit objects. In valueObject property of SearchHit, you will find the Content object that match the given given Query.

Tip: If you you are searching using a unique identifier, for instance using the content id or content remote id criterion, then you can use SearchService::findSingle(), this takes a Criterion and returns a single Content, or throws NotFound exception if none is found.

...