cancel
Showing results for 
Search instead for 
Did you mean: 

Removing Empty Attributes?

Removing Empty Attributes?

Hi,

 

I'm using Magento version 1.9.3.4. How can I stop attributes showing at all instead of it saying NO/N/a there's no attribute attached to a product? 

 

Kind regards

9 REPLIES

Re: Removing Empty Attributes?

Try going to the Manage Attributes interface in admin and finding the attributes you wish to hide.  Then change the "Visible on Product View Page on Front-end" setting to no. 

 

http://docs.magento.com/m1/ee/user_guide/catalog/attribute-frontend-properties.html

----
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution" as appropriate. Thanks!

Re: Removing Empty Attributes?

Would this not hide the attributes on the products which do have those attributes though?

Re: Removing Empty Attributes?

Ah, sorry I missed that requirement. The easiest way to do this is to edit the template or block to not output the row of the table of it’s not got a positive value.
 
----
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution" as appropriate. Thanks!

Re: Removing Empty Attributes?

Sorry how do I do that? kind regards?

Re: Removing Empty Attributes?

This is the line that outputs the product attribute table values: https://github.com/OpenMage/magento-mirror/blob/magento-1.9/app/design/frontend/base/default/templat...

----
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution" as appropriate. Thanks!

Re: Removing Empty Attributes?

HI, I've just noticed the theme I applied the coding is the below? Do I need to add anything to the code?

 

<?php

/**

 * @package     artichoke

 * @copyright   Copyright (c) 2010-2015 MeigeeTeam. (http://www.meigeeteam.com)

 */

 

/**

 * Product additional attributes template

 *

 * @see Mage_Catalog_Block_Product_View_Attributes

 */

?>

<?php

    $_helper = $this->helper('catalog/output');

    $_product = $this->getProduct()

?>

<?php if($_additional = $this->getAdditionalData()): ?>

    <h2><?php echo $this->__('Additional Information') ?></h2>

    <table class="table table-responsive table-bordered" id="product-attribute-specs-table">

        <tbody>

        <?php foreach ($_additional as $_data): ?>

            <tr>

                <th class="label"><?php echo (Mage::app()->getLayout()->checkVersion('1.7.x.x') ? $this->htmlEscape : $this->escapeHtml).($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')</script>

<?php endif;?>

 

 

Re: Removing Empty Attributes?

HI, I've just noticed the theme I applied the coding is the below? Do I need to add anything to the code?

<?php
/**
* @package artichoke
* @copyright Copyright (c) 2010-2015 MeigeeTeam. (http://www.meigeeteam.com)
*/

/**
* Product additional attributes template
*
* @see Mage_Catalog_Block_Product_View_Attributes
*/
?>
<?php
$_helper = $this->helper('catalog/output');
$_product = $this->getProduct()
?>
<?php if($_additional = $this->getAdditionalData()): ?>
<h2><?php echo $this->__('Additional Information') ?></h2>
<table class="table table-responsive table-bordered" id="product-attribute-specs-table">
<tbody>
<?php foreach ($_additional as $_data): ?>
<tr>
<th class="label"><?php echo (Mage::app()->getLayout()->checkVersion('1.7.x.x') ? $this->htmlEscape : $this->escapeHtml).($this->__($_data['label'])) ?></th>
<td class="data"><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
&lt;script type="text/javascript">decorateTable('product-attribute-specs-table')&lt;/script&gt;
<?php endif;?>

Re: Removing Empty Attributes?

It will be much the same. Inside the for loop, you will want to check the value of $_data['value'] and only output lines within the for loop if they're not equal to N/A or false. 

----
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution" as appropriate. Thanks!

Re: Removing Empty Attributes?

I’ll take a look though I’m not sure I’m able to do that. I think it’s something outside of my skills.