Create a collection in Magento
Learn how to create a Magento collection class to retrieve multiple Post model records efficiently.
Lesson Content
We can now query, save & delete records with a resource model, but we can’t yet retrieve a list of records out of the database. This is when a collection comes into play.
Collections are actually considered an extension of the resource model, and will allow us to retrieve many records at once.
They are set up similarly to a model & resource model — very simple.
First, we’ll create our Collection class. The naming of this is a bit different from our model & resource model, which are named directly after the entities they relate to. Rather than also naming this Post, we will create...
Join the discussion!
Comments
Want to comment on this lesson?
Enroll in this course to leave comments.