0

This question already has an answer here:

I am using magento version 1.9 and I need to hide description block if no data found, if data exits the block shows description, if not found, that should be hide.

marked as duplicate by Raphael at Digital Pianism, Rakesh Jesadiya, Rajeev K Tomy, Murtuza Zabuawala, Amit Bera Nov 17 '16 at 11:21

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Which magento version you are workingon? – Nitin Pawar Nov 15 '16 at 4:38
  • magento : 1.9.2.3 – Gem Nov 15 '16 at 4:38
  • 1
    find the file which returns the product description there you can write the condition to check empty field. – Nitin Pawar Nov 15 '16 at 4:42
0

Go to product view page

app/design/frontend/Your-namespace/Your-theme/template/catalog/product/view.phtml

Put your description block code between below condition:

if($_product->getDescription()){
  //description block goes here
}
  • make sure if data exits the description will show – Gem Nov 15 '16 at 4:45
  • Yes it will show if description have data – Prashant Valanda Nov 15 '16 at 4:46
  • pls check the path – Gem Nov 15 '16 at 4:47
  • app/code/ design – Gem Nov 15 '16 at 4:47
  • 1
    app/design/frontend/Your-namespace/Your-theme/template/catalog/product/view.phtml – Adarsh Khatri Nov 15 '16 at 4:52
0

The file can be found here: /app/design/frontend/[theme name]/[package name]/template/catalog/product/view/attribute.phtml

Open the file and search for the following lines:

    <?php foreach ($_additional as $_data): ?>
<tr>
    <th class="label"><?php echo $this->htmlEscape($this->__($_data['label'])) ?></th>
    <td class="data"><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
</tr><?php endforeach; ?>

Replace the entire foreach loop with the following lines of code:

<?php foreach ($_additional 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"><?php echo $this->htmlEscape($this->__($_data['label'])) ?></th>
        <td class="data"><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
    </tr>
    <?php } ?>
<?php endforeach; ?>

<?php foreach ($_additional 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"><?php echo $this->htmlEscape($this->__($_data['label'])) ?></th>
        <td class="data"><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
    </tr>
    <?php } ?>
<?php endforeach; ?>

You can find here: Hide attributes with no value

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