If you look back at the previous code example, you will notice that I'm not only instantiating a product model, but I'm also calling the getCollection()
method. The getCollection()
method is part of the Mage_Core_Model_Abstract
class, meaning, every single model inside Magento can call this method.
A Magento collection is basically a model that contains other models. So instead of using an array to hold a collection of products, we will use a product collection. Collections not only provide a convenient data structure to group models, they also provide special methods that we can use to manipulate and work with a collection of entities.
Some of the most useful collection methods are: