Skip to main content

Magento 2 : How to get custom module collection in module template file

I want to load custom module collection in module template file :

I have my custom module which has table name:tagdata

I want to load "tagdata" table data in my template file.

And yeah I created a grid with UI component.

Please check my model file :

<?php namespace [vendor]\[module]\Model; class Extratags extends \Magento\Framework\Model\AbstractModel { function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { parent::__construct($context, $registry, $resource, $resourceCollection, $data); } protected function _construct() { $this->_init('[vendor]\[module]\Model\ResourceModel\Extratags'); } } 
Sneha Panchal
  • 896
  • 14
  • 31