100 abstract protected function init();
108 return $this->data[
'items'];
117 $this->data[
'items'] =
$items;
126 if (!isset($this->data[
'total_count'])) {
127 $this->data[
'total_count'] = $this->query->getSize();
129 return $this->data[
'total_count'];
138 $this->data[
'total_count'] = $totalCount;
147 if (!isset($this->data[
'search_criteria'])) {
148 $this->data[
'search_criteria'] = $this->query->getCriteria();
150 return $this->data[
'search_criteria'];
168 return $this->resultIteratorFactory->create(
170 'searchResult' => $this,
171 'query' => $this->query,
190 return $this->query->getIdFieldName();
198 return $this->query->getSize();
209 $field = $this->query->getIdFieldName();
211 return $item->getData($field);
213 return $item->getId();
233 $data = $this->query->fetchAll();
234 $this->data[
'items'] = [];
235 if (is_array(
$data)) {
267 if ($itemId !==
null) {
268 if (isset($this->data[
'items'][$itemId])) {
269 throw new \Exception(
270 'Item (' . get_class(
$item) .
') with the same ID "' .
$item->getId() .
'" already exists.' 273 $this->data[
'items'][$itemId] =
$item;
275 $this->data[
'items'][] =
$item;
286 $this->eventManager->dispatch(
'abstract_search_result_load_before', [
'collection' => $this]);
287 if ($this->eventPrefix && $this->eventObject) {
288 $this->eventManager->dispatch($this->eventPrefix .
'_load_before', [$this->eventObject => $this]);
299 $this->eventManager->dispatch(
'abstract_search_result_load_after', [
'collection' => $this]);
300 if ($this->eventPrefix && $this->eventObject) {
301 $this->eventManager->dispatch($this->eventPrefix .
'_load_after', [$this->eventObject => $this]);
getItemId(\Magento\Framework\DataObject $item)
setSearchCriteria(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria=null)
addItem(\Magento\Framework\DataObject $item)
createDataObject(array $arguments=[])
setItems(array $items=null)
setDataInterfaceName($dataInterface)
setTotalCount($totalCount)
__construct(\Magento\Framework\DB\QueryInterface $query, \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\Data\SearchResultIteratorFactory $resultIteratorFactory)