Collection.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sales\Model\ResourceModel\Grid;
  7. use Magento\Framework\Api\Search\SearchResultInterface;
  8. use Magento\Framework\Api\Search\AggregationInterface;
  9. use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
  10. /**
  11. * Class Collection
  12. * Collection for displaying grid of sales documents
  13. */
  14. class Collection extends AbstractCollection implements SearchResultInterface
  15. {
  16. /**
  17. * @var AggregationInterface
  18. */
  19. protected $aggregations;
  20. /**
  21. * @param \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory
  22. * @param \Psr\Log\LoggerInterface $logger
  23. * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
  24. * @param \Magento\Framework\Event\ManagerInterface $eventManager
  25. * @param null|\Zend_Db_Adapter_Abstract $mainTable
  26. * @param string $eventPrefix
  27. * @param string $eventObject
  28. * @param string $resourceModel
  29. * @param string $model
  30. * @param \Magento\Framework\DB\Adapter\AdapterInterface|string|null $connection
  31. * @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource
  32. *
  33. * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  34. */
  35. public function __construct(
  36. \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory,
  37. \Psr\Log\LoggerInterface $logger,
  38. \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
  39. \Magento\Framework\Event\ManagerInterface $eventManager,
  40. $mainTable,
  41. $eventPrefix,
  42. $eventObject,
  43. $resourceModel,
  44. $model = \Magento\Sales\Model\ResourceModel\Grid\Document::class,
  45. $connection = null,
  46. \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null
  47. ) {
  48. $this->_eventPrefix = $eventPrefix;
  49. $this->_eventObject = $eventObject;
  50. $this->_init($model, $resourceModel);
  51. $this->setMainTable($mainTable);
  52. parent::__construct(
  53. $entityFactory,
  54. $logger,
  55. $fetchStrategy,
  56. $eventManager,
  57. $connection,
  58. $resource
  59. );
  60. }
  61. /**
  62. * @return AggregationInterface
  63. */
  64. public function getAggregations()
  65. {
  66. return $this->aggregations;
  67. }
  68. /**
  69. * @param AggregationInterface $aggregations
  70. * @return $this
  71. */
  72. public function setAggregations($aggregations)
  73. {
  74. $this->aggregations = $aggregations;
  75. return $this;
  76. }
  77. /**
  78. * Retrieve all ids for collection
  79. * Backward compatibility with EAV collection
  80. *
  81. * @param int $limit
  82. * @param int $offset
  83. * @return array
  84. */
  85. public function getAllIds($limit = null, $offset = null)
  86. {
  87. return $this->getConnection()->fetchCol($this->_getAllIdsSelect($limit, $offset), $this->_bindParams);
  88. }
  89. /**
  90. * Get search criteria.
  91. *
  92. * @return \Magento\Framework\Api\SearchCriteriaInterface|null
  93. */
  94. public function getSearchCriteria()
  95. {
  96. return null;
  97. }
  98. /**
  99. * Set search criteria.
  100. *
  101. * @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
  102. * @return $this
  103. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  104. */
  105. public function setSearchCriteria(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria = null)
  106. {
  107. return $this;
  108. }
  109. /**
  110. * Get total count.
  111. *
  112. * @return int
  113. */
  114. public function getTotalCount()
  115. {
  116. return $this->getSize();
  117. }
  118. /**
  119. * Set total count.
  120. *
  121. * @param int $totalCount
  122. * @return $this
  123. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  124. */
  125. public function setTotalCount($totalCount)
  126. {
  127. return $this;
  128. }
  129. /**
  130. * Set items list.
  131. *
  132. * @param \Magento\Framework\Api\ExtensibleDataInterface[] $items
  133. * @return $this
  134. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  135. */
  136. public function setItems(array $items = null)
  137. {
  138. return $this;
  139. }
  140. }