Working with Magento collections

In this chapter, we will explore the possibilities of the Magento collections. A Magento collection is a set of entities where you can add filters to customize your result.

In this chapter, we will explore everything that is possible with Magento collections.

Getting ready

Go to the indexController of the helloworld module and create a collectionAction method in it. In this action, we will perform some tests to compare the results.

How to do it...

The next examples show what are the possibilities while working with Magento collections:

  1. Add the following code in the collectionAction method and navigate to the page. This code will return 10 products.
    public function collectionAction () { $productCollection = Mage::getModel('catalog/product') ...

Get Magento 1.8 Development Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.