Models, Resource Models And Collections In Magento

All Magento Models inherit from the Mage_Core_Model_Abstract.Magento splits the model layer up into two parts as you’ve recognized, with the Model handling the business-logic, and the Resource part only dealing with talking to the database .The Resource also has two different types one is Entity and other is Mysql4. We will discuss differences between Magento Models, Resource models and Collections in Magento later on.

Checkout other tutorial of Magento Collection,

How To Create Magento model with proper collection object in Magento:

  1. Model Class
  2. Resource Class
  3. Collection Class
  4. Install Script( Mysql4)

Basic concepts of Magento models, resource models, and collections are following:

Magento Model :

Magento Model is handle all logical operation with database.Its ActiveRecord-like/one-object-one-table Model, and there’s also an Entity Attribute Value (EAV) Model. Each Model also gets a Model Collection. .

Magento Resource Model

Magento’s resource simply connect with the database and performs the CRUD operations. Actually they manage the different reading/writing connections.Its another layer between model and database when you interacting with database.

Magento Collection Model:

Collection referees the collection of contains many models.When we want results based on different model then we need to create collection or we can use existing collection.
It gives us a whole load of convenience methods, making it easier to manipulate lists of entities and reducing the need to write complex sql.