Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

addAttributeToSelect(’…’). Anyone else having trouble understanding this seemingly simple function? 
 
jotu
Member
 
Avatar
Total Posts:  34
Joined:  2008-03-03
Switzerland
 

Hi,
I have added attributes to my products and I’m using observers and/or rewriting models to filter and display products according to these additional attributes. I can’t help noticing that addAttributeToSelect doesn’t actually do anything. For example, adding addAttributeToSelect(’*’) does not return a collection with all available product attributes. At least I am not getting all the attributes that Mage::getSingleton(’catalog/config’)->getProductAttributes() says are available. In particular I am not getting any of the custom attributes. Nor will using addAttributeToSelect(’my_attribute’) guarantee that “my_attribute” is available in the collection. Interestingly (or I should say strangely) when I use addAttributeToFilter(’my_attribute’, array of values) I do get the field “my_attribute” in the collection.
Needless to say, I am confused about what addAttributeToSelect actually does. Am I missing some vital step here which will ensure that addAttributeToSelect(’my_attribute’) really does add “my_attribute” to the collection? Thanks for any hints or advice.
Best,
Simon

 
Magento Community Magento Community
Magento Community
Magento Community
 
greenshopping
Jr. Member
 
Total Posts:  10
Joined:  2010-09-28
 

Just in case anyone else ends up here looking for the answer, you’ll find it here in the answer to my Stackoverflow question

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top