SearchResults.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Api;
  7. /**
  8. * SearchResults Service Data Object used for the search service requests
  9. */
  10. class SearchResults extends AbstractSimpleObject implements SearchResultsInterface
  11. {
  12. const KEY_ITEMS = 'items';
  13. const KEY_SEARCH_CRITERIA = 'search_criteria';
  14. const KEY_TOTAL_COUNT = 'total_count';
  15. /**
  16. * Get items
  17. *
  18. * @return \Magento\Framework\Api\AbstractExtensibleObject[]
  19. */
  20. public function getItems()
  21. {
  22. return $this->_get(self::KEY_ITEMS) === null ? [] : $this->_get(self::KEY_ITEMS);
  23. }
  24. /**
  25. * Set items
  26. *
  27. * @param \Magento\Framework\Api\AbstractExtensibleObject[] $items
  28. * @return $this
  29. */
  30. public function setItems(array $items)
  31. {
  32. return $this->setData(self::KEY_ITEMS, $items);
  33. }
  34. /**
  35. * Get search criteria
  36. *
  37. * @return \Magento\Framework\Api\SearchCriteria
  38. */
  39. public function getSearchCriteria()
  40. {
  41. return $this->_get(self::KEY_SEARCH_CRITERIA);
  42. }
  43. /**
  44. * Set search criteria
  45. *
  46. * @param SearchCriteriaInterface $searchCriteria
  47. * @return $this
  48. */
  49. public function setSearchCriteria(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria)
  50. {
  51. return $this->setData(self::KEY_SEARCH_CRITERIA, $searchCriteria);
  52. }
  53. /**
  54. * Get total count
  55. *
  56. * @return int
  57. */
  58. public function getTotalCount()
  59. {
  60. return $this->_get(self::KEY_TOTAL_COUNT);
  61. }
  62. /**
  63. * Set total count
  64. *
  65. * @param int $count
  66. * @return $this
  67. */
  68. public function setTotalCount($count)
  69. {
  70. return $this->setData(self::KEY_TOTAL_COUNT, $count);
  71. }
  72. }