Video Lesson: Create a resource model in Magento

Create a resource 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 resource model in Magento

Learn how to create a Magento resource model to link a Post model to the macademy_blog_post database table.

Lesson Content

We probably want our model linked to a table in the database. This is done by creating whatโ€™s called a resource model. Resource models are what relate a model to its related database table.

Letโ€™s create a new folder under Model named ResourceModel, and under that we will create a new PHP file with the name of our resource model, which will also be Post.

This will be similar to our model. Letโ€™s open up our PHP tag, declare strict types, and set our namespace to Macademy\Blog\Model\ResourceModel.

Next we will create our Post class, and this will extend AbstractDb from `Magen...

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.