Php Flow » Magento

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 recognised, 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 Models, Resource models and Collections in Magento later on.

To build a model with proper collection object in Magento you need 4 things:

1 – model class
2 – resource class
3 – collection class
4 – install script( Mysql4)

Basic concepts of models, resource models, and collections are follwoing:

model :

Magento Models 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. .

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 beetween model and database when you intracting with database.

collection model:

Collection referes the collection of models.it contains many models.When we want results based on diffrent 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.

Did you enjoy this article? Share it!

About the Author:

Hi, This is Parvez Alam from India. I am software developer with 4 years’ experience in web development. I have submitted articles on PHP, Mysql, Magento,CSS, HTML, jQuery, web designing and social API. You can subscribe to my blog via RSS/Twitter/Google plus and Facebook.

Random Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>