I want to get all the attributes which are not empty for a given product. Tried various suggestions in the web, but didn't work,
Any suggestion will be appreciated.
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityyou can get attribute in list page
e.g if machinemaker is you atttribute then in manage attribute it will be represented as machine_maker attribute code and you can get this using : $_product->getMachineMaker();
and if you wannt non empty attribute value then use this like below.it will display the attribute value if it is not empty.
if($_product->getMachineMaker()) { echo "
Machine Make : ".$_product->getMachineMaker()."
" ; }I have written the play script to fetch product attributes value that are not empty and it worked.
require_once("app/Mage.php");
Mage::app('');
$product_id = 8;
$product = Mage::getModel('catalog/product')->load($product_id);
$attributes = $product->getAttributes();
foreach ($attributes as $attribute) {
if(!is_null($attribute->getFrontendLabel()) && ((string)$attribute- >getFrontend()->getValue($product) != '')){
$attributeLabel = $attribute->getFrontendLabel();
$value = $attribute->getFrontend()->getValue($product);
echo $attributeLabel . '-' . $value; echo "<br />";
}
}