0

i have 3 category on my website Mens, Womens, Childrens. I added another attribute as Sub Category which is only for Childrens to identify weather its a Boy or a Girl products. But the problem is that Sub Category is showing in Mens and Womens Category as N/A. So how can i hide that Sub Category in just Mens & Womens. Below is the screenshot.

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

  • Why don't you create separate attribute set for this ? otherwise you should add some condition in your template that not show all those attributes where there is no value specified. – Naveed Asim Sep 9 '18 at 4:19
  • You want do : if the attribute value is N/A, you don't display it ? – PЯINCƏ Sep 9 '18 at 16:01
  • yes as sub category is only for childrens and showing NA in mens and womens section seems pointless. – user66190 Sep 10 '18 at 6:02
0

app/design/frontend/{package}/{themename}/template/catalog/product/view/attributes/phtml

<?php
    $_helper = $this->helper('catalog/output');
    $_product = $this->getProduct()
?>
<?php if($_additional = $this->getAdditionalData()): ?>
   <table class="table table-striped push-top">
        <tbody>
        <?php foreach ($_additional as $_data): ?>
            <?php if( $_helper->productAttribute($_product, $_data['value'], $_data['code']) != "N/A") :?> //Added this condition
                <tr>
                    <th><?php echo $this->escapeHtml($this->__($_data['label'])) ?></th>
                    <td><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
                </tr>
            <?php endif;?>
        <?php endforeach; ?>
        </tbody>
    </table>
<?php endif;?>

Update:

Replace

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

with :

<?php foreach ($_additional as $_data): ?>
    <?php if( $_helper->productAttribute($_product, $_data['value'], $_data['code']) != "N/A") :?> //Added this condition
        <tr>
            <th><?php echo $this->escapeHtml($this->__($_data['label'])) ?></th>
            <td><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
        </tr>
    <?php endif;?>
<?php endforeach; ?>

Update2:

<?php foreach ($_additional as $_data): ?>
    <?php if(!empty($_helper->productAttribute($_product, $_data['value'], $_data['code']))) :?> //Added this condition
        <tr>
            <th><?php echo $this->escapeHtml($this->__($_data['label'])) ?></th>
            <td><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
        </tr>
    <?php endif;?>
<?php endforeach; ?>
  • Should i replace it with anything or simply add this line ? – user66190 Sep 10 '18 at 10:00
  • What should you replace it with anything ? you go to this file : app/design/frontend/{package}/{themename}/template/catalog/product/view/attributes/phtml then you add this contion ` <?php if( $_helper->productAttribute($_product, $_data['value'], $_data['code']) != "N/A") :?>` like my exemple – PЯINCƏ Sep 10 '18 at 10:11
  • did not work .... i copy pasted your code by replacing my existing one. – user66190 Sep 10 '18 at 10:14
  • Share me please your original code – PЯINCƏ Sep 10 '18 at 10:16
  • how can i copy paste the code as its showing to long – user66190 Sep 10 '18 at 10:29
-1

Please Copy this file in your theme direcrtory if it not available in your active theme:

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

And replace this code

<?php foreach ($_additional as $_data): ?>
        <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 endforeach; ?>

with following code

<?php foreach ($_additional as $_data): ?>
        <?php if($_data['value'] != "N/A"): ?>
            <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 endif; ?>
    <?php endforeach; ?>

This will hide attributes with value "N/A".

  • i tried it didn't work. – user66190 Sep 10 '18 at 6:15
  • I think your product information block shows from custom template file, Please enable template path hint and check this product info. Shows from which file and apply condition in that file. – Kishor Thummar Sep 10 '18 at 6:21
  • i tried finding it using pathfinder, but the area is not highlighted and no location showed. any other way to know this ? – user66190 Sep 10 '18 at 7:36
  • can you just share screenshot with enabled path hints for that block? – Kishor Thummar Sep 10 '18 at 7:54
  • i added the screenshot in my main post above. Thanks – user66190 Sep 10 '18 at 8:08

Your Answer

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