Outside of the source code, is there any extensive documentation on the Magento ORM? I get the basics, and can usually dig through the Mage code base, litter it with Mage::Log calls and figure out something that works, but my efficiency would go way up if I had a high level overview of how the models are intended to be used. How do the aggregate methods work, what's the best way to join, when should you extend the models, when's the best time to use the eav models vs. the non-eav ones, etc.
Something like the Django Model Documentation, but for Magento.
Object Relational Mapping (ORM) is a programming technique for converting between types of data and objects in OOP. There are 2 types of ORM: Convert different types of data to objects. Convert objects to various types of data.
Models : Models are where your main business logic should be handled and is a single instance of an object. The model will use the resource model to talk to the database and get/set data for it on save() and load() . Resource Model : A resource model is where your main C.R.U.D happens (Create, Read, Update and delete).
Repository Pattern separates the database logic and maps it to the objects in the business logic. It works with the domain entities and performs database logic. In the Repository pattern, the data objects, the database logic, and the business logic connect to each other using interfaces.
While there isn't much documentation on the ORM, here were a few pages that greatly helped in my understanding of the database structure which will help you understand everything else:
http://www.magentocommerce.com/wiki/development/magento_database_diagram http://www.magentocommerce.com/boards/viewthread/7359/
Since this question was answered, some documentation has been created on the ORM at the magento knowledge base.
Introductory information: http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-5-magento-models-and-orm-basics
Advanced ORM usage and the EAV system: http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-7-advanced-orm-entity-attribute-value
Working with the Varien collections (lazy loading, filtering, etc...): http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-8-varien-data-collections
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With