How to fetch data from a database and display it in Magento 2

Blog Image

Magento 2 Model

To get information from our table, we need to create a model which extends from AbstractModel. Models are used to connect to the database, and process data from and to it. To create that, we need to prepare a file entitled Data.php in app/code/CleverCode/HelloWorld/Model with the following contents:

Learn more

Follow the fox_

Pursuant to the Personal Data Protection Law (Official Gazette no.922/2016) I hereby agree to the processing of my personal data for marketing purposes by Clever Code Marcin Baranowski, with its registered office at 218, ul. Suraska 1, Bialystok (15-093).

I hereby express my consent to receive commercial information in electronic fashion from Clever Code Marcin Baranowski, with its registered office at 218, ul. Suraska 1, Bialystok (15-093), Suraska 1 St., commercial information in electronic way.

These agreements may be canceled at any time. Personal data will not be shared with any other recipients. You have the right to access and amend this data at any time.