Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace CompanyModuleModelResourceModelCustomGrid;
- use MagentoFrameworkApiSearchSearchResultInterface;
- use MagentoFrameworkSearchAggregationInterface;
- use CompanyModuleModelResourceModelCustomCollection as CustomCollection;
- class MyCollection extends CustomCollection implements SearchResultInterface{
- /**
- * @var AggregationInterface
- */
- protected $aggregations;
- protected $request;
- public function __construct(
- MagentoFrameworkDataCollectionEntityFactoryInterface $entityFactory,
- PsrLogLoggerInterface $logger,
- MagentoFrameworkDataCollectionDbFetchStrategyInterface $fetchStrategy,
- MagentoFrameworkEventManagerInterface $eventManager,
- MagentoStoreModelStoreManagerInterface $storeManager,
- MagentoFrameworkAppRequestInterface $request,
- $mainTable,
- $eventPrefix,
- $eventObject,
- $resourceModel,
- $model = 'MagentoFrameworkViewElementUiComponentDataProviderDocument',
- $connection = null,
- MagentoFrameworkModelResourceModelDbAbstractDb $resource = null
- ) {
- $this->addFilterToMap('customer_name','firstname');
- parent::__construct(
- $entityFactory,
- $logger,
- $fetchStrategy,
- $eventManager,
- $storeManager,
- $connection,
- $resource
- );
- $this->request = $request;
- $this->_eventPrefix = $eventPrefix;
- $this->_eventObject = $eventObject;
- $this->_init($model, $resourceModel);
- $this->setMainTable($mainTable);
- }
- /**
- * @return AggregationInterface
- */
- public function getAggregations()
- {
- return $this->aggregations;
- }
- /**
- * @param AggregationInterface $aggregations
- * @return $this
- */
- public function setAggregations($aggregations)
- {
- $this->aggregations = $aggregations;
- }
- /**
- * Retrieve all ids for collection
- * Backward compatibility with EAV collection
- *
- * @param int $limit
- * @param int $offset
- * @return array
- */
- public function getAllIds($limit = null, $offset = null)
- {
- return $this->getConnection()->fetchCol($this->_getAllIdsSelect($limit, $offset), $this->_bindParams);
- }
- /**
- * Get search criteria.
- *
- * @return MagentoFrameworkApiSearchCriteriaInterface|null
- */
- public function getSearchCriteria()
- {
- return null;
- }
- /**
- * Set search criteria.
- *
- * @param MagentoFrameworkApiSearchCriteriaInterface $searchCriteria
- * @return $this
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- */
- public function setSearchCriteria(MagentoFrameworkApiSearchCriteriaInterface $searchCriteria = null)
- {
- return $this;
- }
- /**
- * Get total count.
- *
- * @return int
- */
- public function getTotalCount()
- {
- return $this->getSize();
- }
- /**
- * Set total count.
- *
- * @param int $totalCount
- * @return $this
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- */
- public function setTotalCount($totalCount)
- {
- return $this;
- }
- /**
- * Set items list.
- *
- * @param MagentoFrameworkApiExtensibleDataInterface[] $items
- * @return $this
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- */
- public function setItems(array $items = null)
- {
- return $this;
- }
- protected function _renderFiltersBefore() {
- $custId = $this->getRequest()->getParam('id');
- $this->addFieldToFilter('main_table.customer_id',$custId);
- $joinTable = $this->getTable('customer_entity');
- $this->getSelect()->join($joinTable.' as customer','main_table.customer_id = customer.entity_id',
- array('customer_name'=>"CONCAT(firstname,' ',lastname)"));
- parent::_renderFiltersBefore();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement