Why does my attribute return only "No" (even though some products have the attribute set to "Yes") when I try to access it from a collection, but does return "Yes" or "No" appropriately I load the product individually?
$attributes = array('my_attribute','another_attribute');
$productsCollection = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect($attributes);
$productsCollection->load();
foreach ($productsCollection as $_product) {
$value = $_product->getAttributeText('my_attribute'); // only returns "No";
}
I can get it to return the proper value if I reload the product individually, but that's way too inefficient for my needs.
$attributes = array('my_attribute','another_attribute');
$productsCollection = Mage::getSingleton('catalog/product')
->getCollection()
->addAttributeToSelect($attributes);
$productsCollection->load();
foreach ($productsCollection as $_product) {
// Reload product individually
$_product = Mage::getSingleton('catalog/product')
->load($_product->getId());
$value = $_product->getAttributeText('my_attribute');
//return "Yes" and "No" appropriately;
}
How can I efficiently, grab "select" attribute values for thousands of products?