0

i have this code to hide product attributes which has no value (empty attributes) from frontend:

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

i have copied this to my groupview.phtml (my alternative attributes file) like this:

<?php
    $_helper = $this->helper('catalog/output');
    $_product = $this->getProduct()
?>
<?php if($_additionalgroup = $this->getAdditionalData()): ?>
<div class="box-collateral box-additional">
    <h2><?php echo $this->__('Additional Information') ?></h2>

    <?php $i=0; foreach ($_additionalgroup as $_additional): $i++; ?>
    <div class="attributesgroups-title">
        <h3 style="margin:0; color:white;"><?php echo $this->__( $_additional['title'] )?></h3>
        </div>
        <table style="border-radius: 0 0 2px 2px;" class="data-table" id="product-attribute-specs-table-<?php echo $i?>">
            <col width="25%" />
            <col />
            <tbody>
            <?php foreach ($_additional['items'] as $_data): ?>
            <?php $_attribute = $_product->getResource()->getAttribute($_data['code']);
    if (!is_null($_product->getData($_attribute->getAttributeCode())) && ((string)$_attribute->getFrontend()->getValue($_product) != '')) { ?>
                <tr>
                    <th class="label"><img src="<?php echo $this->getSkinUrl('images/attributes/'.$_data['code'].'.png')?>" alt="<?php echo $this->htmlEscape($this->__($_data['label'])) ?>" /><span class="separator">|</span><?php echo $this->htmlEscape($this->__($_data['label'])) ?></th>
                    <td class="data"><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
                </tr>
            <?php endforeach; ?>
            </tbody>
        </table>
        <script type="text/javascript">decorateTable('product-attribute-specs-table-<?php echo $i?>')</script>
    <?php endforeach; ?>

</div>
<?php endif;?>

but i get this error:

Parse error: syntax error, unexpected 'endforeach' (T_ENDFOREACH) in /attributes.phtml on line 24

1 Answer 1

0

Your if statement isn't closed:

if (!is_null($_product->getData($_attribute->getAttributeCode())) && ((string)$_attribute->getFrontend()->getValue($_product) != '')) { ?>

You need a closing } before the endforeach.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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