1

I wrote a simple code for a custom tab to display all atrributes that had a value. But it's returning system attributes that clearly should not be displayed. In the attributes management page in Admin, I checked and triple checked to make sure these attributes were set to NOT display. I refreshed all indexes and flushed all cache, but still showing. Any ideas why this is happening?

Code below, for reference.

$_product = $this->getProduct(); 
$attributes = Mage::getResourceModel('catalog/product_attribute_collection')
    ->getItems();
foreach ($attributes as $attribute){

    $productAttributeCode=$attribute->getAttributeCode();
    $productAttributeData=$_product->getData($productAttributeCode);

    if ($productAttributeData > ""){
        if ($productAttributeCode != "status"){ 
            echo '<div class="std">';
            echo $attribute->getFrontendLabel();
            echo ': ';
            //echo $productAttributeCode;
            //echo ': ';
            echo $productAttributeData;
            echo '</div>';
            }
        }
    }
0

You should check if attribute is visible on frontend:

if ($attribute->getIsVisibleOnFrontend()) {
    (...)
}
  • That particular function doesn't return any value for me, and I can't find any info on it anywhere on the web :-/ I just hard coded a big long conditional statement to remove all the system ones for now – MCP Media Dec 1 '15 at 18:18
  • Put this: "print_r($attribute->getData());" in foreach loop, and show me what you see. – SeStro Dec 1 '15 at 19:23
  • Interesting... The output was too long for to post in this comment field, but I think I see something... ()Array ( [entity_type_id] etc etc etc ---deleted a bunch to fit comment--- [is_visible] => 1 ---deleted a bunch to fit comment--- [is_visible_on_front] => 0 [is_html_allowed_on_front] => 0 – MCP Media Dec 9 '15 at 18:57

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.