0

visit link , search for word " abc" using CTRL + F,

you can see attributes : "Brand" & " charactar"

enter link description here

we gave attribute values as "abc" for lot of attributes.

we want to hide the attribute in product view page if the value ="abc"

we are using following code displaying attributes in product view page :

app/design/frontend/default/em0113/template/catalog/product/view/attributes.phtml

<?php
    $_helper = $this->helper('catalog/output');
    $_product = $this->getProduct()
?>
<?php if($_additional = $this->getAdditionalData()): ?>

    <div class="fp1"><?php $Pro_name =$_product->getName();?>
    <h2><?php echo $this->__('Specifications Of '."$Pro_name") ?></h2><br/><br/>


    <table class="data-table" id="product-attribute-specs-table">
        <col width="25%" />
        <col />
        <tbody>
        <?php foreach ($_additional as $_data): ?>

        <?php $_attribute = $_product->getResource()->getAttribute($_data['code']);
       if (!is_null($_product->getData($_attribute->getAttributeCode())) && (trim((string)$_attribute->getFrontend()->getValue($_product)) != '')) { ?>
        <?php if ($_data['code'] == 'gendernew'): ?>

        <tr><th colspan="3"><?php echo $this->__('') ?></th></tr>
        <th class = "tablehead" colspan="3" > GENERAL </th>
        <?php elseif ($_data['code'] == 'productweight'): ?>



        <tr><th class = "tablehead" id="prod_dim" colspan="3"><p style="background: rgb(255, 255, 255) none repeat scroll 0% 0% ! important; color: rgb(255, 255, 255); width: 100%; padding-top: 10px; padding-right: 10px; padding-left: 10px; padding-bottom: 0px ! important;" class="Product_dim">Product Dimension</p><?php echo $this->__('PRODUCT DIMENSION') ?></th></tr>
        <?php endif; ?>
            <tr>
                <th class="label"><?php echo $this->escapeHtml($this->__($_data['label'])) ?></th>
                <td class="data"><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
            </tr>
            <?php } ?>
        <?php endforeach; ?>
        </tbody>
    </table>
    </div>


    <script type="text/javascript">decorateTable('product-attribute-specs-table')</script>
<?php endif;?>

<?php

$attribute_value = 'xyz ';
if (strlen($attribute_value) > 0)
{
   // code to display the value
}

?>
2

Just validate it in the first line after foreach:

...
<tbody>
    <?php foreach ($_additional as $_data): ?>
    <?php $_attribute = $_product->getResource()->getAttribute($_data['code']); 
    if($_attribute->getFrontend()->getValue($_product) == 'abc') {
        continue;
    }
    ?>
...
  • i added like this : pastebin.com/7ZXxwSGn please check link – Baby in Magento Feb 1 '16 at 10:13
  • there is a syntax problem, please check it with an IDE: ... ->getValue($_product) == 'abc') ... – MauroNigrele Feb 1 '16 at 10:16
  • please check link and updated code : pastebin.com/k4ZFV9uc – Baby in Magento Feb 1 '16 at 10:18
  • for what? just try it.. – MauroNigrele Feb 1 '16 at 10:19
  • i updated your code, getting this error again : Parse error: syntax error, unexpected '}' in app/design/frontend/default/em0113/template/catalog/product/view/attributes.phtml on line 72 – Baby in Magento Feb 1 '16 at 10:20

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.