Magento 2 Development Workshop Learn More

Magento 2 for Beginners

10 lessons

Resource Model in Magento 2

In the previous lesson we learned what is a Model in Magento 2. To recap, a model is a class that represents an entity from a database. A model in a Magento 2 module is usually created together with a resource model class and a collection class. We will learn about collections in our next lesson.

In this lesson, we are going to learn about a Resource Model class that is used in conjunction with a Model. I will answer questions on how to create a Resource Model, what are the capabilities and show an usage example. After this lesson, you will know what a Resource Model is and how to use it in your custom Magento 2 extension.

Lesson Overview

In this lesson we are going to learn the following:

  • What Resource Model in Magento 2 is?
  • Resource Model class capabilities
  • When to use a Resource Model?
  • How to create a Resource Model?
  • Examples of usages and implementations

Next Lesson

In the next lesson we are going to learn about a Collection class and its capabilities in Magento 2.