Skip to content

Instantly share code, notes, and snippets.

@jwohlfeil
Created February 14, 2017 12:39
Show Gist options
  • Save jwohlfeil/7bb7dcdcf15ec0cdf06b80706c571047 to your computer and use it in GitHub Desktop.
Save jwohlfeil/7bb7dcdcf15ec0cdf06b80706c571047 to your computer and use it in GitHub Desktop.
<?php
$_product->getThisattribute();
$_product->getAttributeText('thisattribute');
$_product->getResource()->getAttribute('thisattribute')->getFrontend()->getValue($_product);
$_product->getData('thisattribute');
// The following returns the option IDs for an attribute that is a multiple-select field:
$_product->getData('color'); // i.e. 456,499
// The following returns the attribute object, and instance of Mage_Catalog_Model_Resource_Eav_Attribute:
$_product->getResource()->getAttribute('color'); // instance of Mage_Catalog_Model_Resource_Eav_Attribute
// The following returns an array of the text values for the attribute:
$_product->getAttributeText('color') // Array([0]=>'red', [1]=>'green')
// The following returns the text for the attribute
if ($attr = $_product->getResource()->getAttribute('color')):
echo $attr->getFrontend()->getValue($_product); // will display: red, green
endif;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment