0

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.

0

you 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()."

" ; }

0

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 />";       
    }
} 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.