Advertisement
Guest User

Untitled

a guest
Jan 12th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.36 KB | None | 0 0
  1. namespace CompanyModuleModelResourceModelCustomGrid;
  2.  
  3. use MagentoFrameworkApiSearchSearchResultInterface;
  4. use MagentoFrameworkSearchAggregationInterface;
  5. use CompanyModuleModelResourceModelCustomCollection as CustomCollection;
  6.  
  7.  
  8. class MyCollection extends CustomCollection implements SearchResultInterface{
  9.  
  10. /**
  11. * @var AggregationInterface
  12. */
  13. protected $aggregations;
  14. protected $request;
  15.  
  16. public function __construct(
  17. MagentoFrameworkDataCollectionEntityFactoryInterface $entityFactory,
  18. PsrLogLoggerInterface $logger,
  19. MagentoFrameworkDataCollectionDbFetchStrategyInterface $fetchStrategy,
  20. MagentoFrameworkEventManagerInterface $eventManager,
  21. MagentoStoreModelStoreManagerInterface $storeManager,
  22. MagentoFrameworkAppRequestInterface $request,
  23. $mainTable,
  24. $eventPrefix,
  25. $eventObject,
  26. $resourceModel,
  27. $model = 'MagentoFrameworkViewElementUiComponentDataProviderDocument',
  28. $connection = null,
  29. MagentoFrameworkModelResourceModelDbAbstractDb $resource = null
  30.  
  31. ) {
  32. $this->addFilterToMap('customer_name','firstname');
  33. parent::__construct(
  34. $entityFactory,
  35. $logger,
  36. $fetchStrategy,
  37. $eventManager,
  38. $storeManager,
  39. $connection,
  40. $resource
  41. );
  42. $this->request = $request;
  43. $this->_eventPrefix = $eventPrefix;
  44. $this->_eventObject = $eventObject;
  45. $this->_init($model, $resourceModel);
  46. $this->setMainTable($mainTable);
  47. }
  48.  
  49. /**
  50. * @return AggregationInterface
  51. */
  52. public function getAggregations()
  53. {
  54. return $this->aggregations;
  55. }
  56.  
  57. /**
  58. * @param AggregationInterface $aggregations
  59. * @return $this
  60. */
  61. public function setAggregations($aggregations)
  62. {
  63. $this->aggregations = $aggregations;
  64. }
  65.  
  66.  
  67. /**
  68. * Retrieve all ids for collection
  69. * Backward compatibility with EAV collection
  70. *
  71. * @param int $limit
  72. * @param int $offset
  73. * @return array
  74. */
  75. public function getAllIds($limit = null, $offset = null)
  76. {
  77. return $this->getConnection()->fetchCol($this->_getAllIdsSelect($limit, $offset), $this->_bindParams);
  78. }
  79.  
  80. /**
  81. * Get search criteria.
  82. *
  83. * @return MagentoFrameworkApiSearchCriteriaInterface|null
  84. */
  85. public function getSearchCriteria()
  86. {
  87. return null;
  88. }
  89.  
  90. /**
  91. * Set search criteria.
  92. *
  93. * @param MagentoFrameworkApiSearchCriteriaInterface $searchCriteria
  94. * @return $this
  95. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  96. */
  97. public function setSearchCriteria(MagentoFrameworkApiSearchCriteriaInterface $searchCriteria = null)
  98. {
  99. return $this;
  100. }
  101.  
  102. /**
  103. * Get total count.
  104. *
  105. * @return int
  106. */
  107. public function getTotalCount()
  108. {
  109. return $this->getSize();
  110. }
  111.  
  112. /**
  113. * Set total count.
  114. *
  115. * @param int $totalCount
  116. * @return $this
  117. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  118. */
  119. public function setTotalCount($totalCount)
  120. {
  121. return $this;
  122. }
  123.  
  124. /**
  125. * Set items list.
  126. *
  127. * @param MagentoFrameworkApiExtensibleDataInterface[] $items
  128. * @return $this
  129. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  130. */
  131. public function setItems(array $items = null)
  132. {
  133. return $this;
  134. }
  135.  
  136. protected function _renderFiltersBefore() {
  137.  
  138.  
  139. $custId = $this->getRequest()->getParam('id');
  140.  
  141. $this->addFieldToFilter('main_table.customer_id',$custId);
  142. $joinTable = $this->getTable('customer_entity');
  143. $this->getSelect()->join($joinTable.' as customer','main_table.customer_id = customer.entity_id',
  144. array('customer_name'=>"CONCAT(firstname,' ',lastname)"));
  145.  
  146. parent::_renderFiltersBefore();
  147. }
  148. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement