In Magento 1.5 on the product page, I created a product collection (for related products) like this (I've omitted filters):
// $_products = Mage::getResourceModel('catalog/product_collection') // this variation makes no difference.
$_products = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('name')
->addAttributeToSelect('url_path')
->addAttributeToSelect('price')
->addAttributeToSelect('some_text_attribute')
->addAttributeToSelect('some_dropdown_attr'); // does not work for dropdown/multiselect apparently
Now if I echo $_products->getSelect()
I see that adding the dropdown attribute did nothing to modify the select. So the data for 'some_dropdown_attr' is not available that way. Isn't there a way to add it to the select. And if not, there certainly must be a way to get the value(s) of any dropdown (or multiselect) attribute for a certain product.
$_text_attr[] = array();
$_dropdown_attr[] = array();
foreach($_products as $_product) {
$_text_attr[] = $_product->getData('some_text_attribute');
// 1.) get resource - doesn't work
// $_dropdown_attr[] = $_product->getResource()->getAttribute('some_dropdown_attr')->getFrontend()->getValue($_product); // results in array of "No"
// 2.) get attribute text - doesn't work
// $_dropdown_attr[] = $_product->getAttributeText('some_dropdown_attr'); // results in array of NULLS.
// Get attributes - doesn't work - array of "No". Also, even if it did work it seems idiotic to have to get all product attributes just to get the value of one
// $_attrs = $_product->getAttributes();
// $_dropdown_attr[] = $_attrs['some_dropdown_attr']->getFrontend()->getValue($_product);
}
id
using Chrome's "Inspect Element." The id = the attribute code.$_product->getAttributeText('some_dropdown_attr')