Working with Magento collections
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.
Tip
All collections inherit from Varien_Data_Collection
.
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 ...
Get Magento PHP Developer's Guide - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.