objectManager = $objectManager; $this->documentFactory = $documentFactory; $this->aggregationFactory = $aggregationFactory; } /** * Create Query Response instance * * @param mixed $rawResponse * @return \Magento\Framework\Search\Response\QueryResponse */ public function create($rawResponse) { $documents = []; foreach ($rawResponse['documents'] as $rawDocument) { /** @var \Magento\Framework\Api\Search\Document[] $documents */ $documents[] = $this->documentFactory->create($rawDocument); } /** @var \Magento\Framework\Search\Response\Aggregation $aggregations */ $aggregations = $this->aggregationFactory->create($rawResponse['aggregations']); return $this->objectManager->create( \Magento\Framework\Search\Response\QueryResponse::class, [ 'documents' => $documents, 'aggregations' => $aggregations ] ); } }