Magento addAttributeToFilter() and addAttributeToSelect()

These two Magento functions looks more like there is no obvious difference between them, but there is.

addAttributeToFilter(‘some_attribute1’,‘attribute_value’) filters a Magento entity collection (e.g Products, categories) by only selecting entities that has ‘some_attribute’ equal to ‘attribute_value’ while

addAttributeToSelect(‘some_attribute2’) tells Magento to return add ‘some_attributes’ to the set of properties that would be returned for a collection of entities.

A combination of these two functions could be likened to sql SELECT 'some_attribute2' FROM Table WHERE 'some_attribute1'='attribute_value'

Tags: phpmagentodevelopersqlecommercedebugging