Video Lesson: Create a model in Magento

Create a model in Magento

This is premium content

Only available to enrolled or University students.
Join today to unlock all lessons in this course.

Create a model in Magento

Learn how to create a Magento 2 model class for a blog post entity using AbstractModel.

Lesson Content

We’re going to set up all of our backend database layer files now in their entirety.

A model represents any data entity in Magento. It doesn’t necessarily need to be linked to a database either, as a model can represent any kind of data entity.

Let us create a model by creating a Model folder in our module directory. Then we will create a file for the name of our model. Since our first model is a post, we will create a file named Post.php.

Let’s open up our PHP tag and declare strict types, set the namespace for this new class to Macademy\Blog\Model, then create this class named...

Premium content

Enroll to unlock the full content and all course materials.

Maggie

Hey, I'm Maggie! 👋

Ask me anything.

Want to chat with Maggie?

Enroll in this course for AI tutor access.

Comments

Join the discussion!

Comments

Want to comment on this lesson?

Enroll in this course to leave comments.