31 private $documentFactory;
36 private $searchResultFactory;
41 private $attributeValueFactory;
52 BaseSearchResultFactory $searchResultFactory,
55 $this->hydrator = $hydrator;
56 $this->documentFactory = $documentFactory;
57 $this->searchResultFactory = $searchResultFactory;
58 $this->attributeValueFactory = $attributeValueFactory;
76 $itemData = $this->hydrator->extract(
$item);
77 $itemId = $itemData[$idFieldName];
78 $attributes = $this->createAttributes($idFieldName, $itemData);
80 $document = $this->documentFactory->create();
81 $document->setId($itemId);
83 $documents[] = $document;
86 $searchResult = $this->searchResultFactory->create();
87 $searchResult->setItems($documents);
88 $searchResult->setTotalCount($totalCount);
98 private function createAttributes(
string $idFieldName, array $itemData): array
102 $idFieldNameAttribute = $this->attributeValueFactory->create();
103 $idFieldNameAttribute->setAttributeCode(
'id_field_name');
104 $idFieldNameAttribute->setValue($idFieldName);
105 $attributes[
'id_field_name'] = $idFieldNameAttribute;
107 foreach ($itemData as $key =>
$value) {
108 $attribute = $this->attributeValueFactory->create();
create(array $items, $totalCount, SearchCriteriaInterface $searchCriteria, $idFieldName)
__construct(HydratorInterface $hydrator, DocumentFactory $documentFactory, BaseSearchResultFactory $searchResultFactory, AttributeValueFactory $attributeValueFactory)