Create collection in Magento 2
Posted at: September 21, 2018 2:13 PM
Create Model File Allnews.php
Rsgitech\News\Model\Allnews.php
Create Resource Model
Rsgitech\News\Model\ResourceModel\Allnews.php
Define table in resource model
Create Collection
Rsgitech\News\Model\ResourceModel\Allnews\Collection.php
Define model and resource model
View Collection on Controller Action
Rsgitech\News\Controller\Adminhtml\AllNews\Index.php
View collection on controller
Then run below commands
Complete!!
Download source code: Download
This lesson also available on YouTube
More Posts - Magento 2 Module Development
- Create admin menu in magento 2
- Create system config in magento 2
- Create helper and get system config value Magento 2
- How to create table and install sample data in Magento 2
- Create collection in Magento 2
- Create admin grid listing in Magento 2
- How to add grid items in Magento 2
- How to edit grid items in Magento 2
- How to delete grid items in Magento 2
- How to show collection on frontend with pagination in Magento 2
- How to get single record from collection in Magento 2