0

How can i hide empty attributes from compare product? is it possible ? if yes how ? For better understanding i attached image please look in it.

Thank you in advance. enter image description here

2

2 Answers 2

-1

I think you can achieve this by editing the .phtml file that is generating this view. I suggest that you enable template hints (http://help.sweettoothrewards.com/article/434-how-do-i-turn-on-template-path-hints) to locate which file to change.

Then you just need to check, if the attribute is empty do not display it, something like this could work:

if (!empty($product->getData('your_attribute_here'))) {
    echo $product->getData('your_attribute_here');
}

If the file that is generating this view is a magento core file, do not hack it, instead create your own .phtml for this in one of your modules. Check this answer: https://magento.stackexchange.com/a/16205/5913 for details on how to do this.

6
  • Thanx for you response.. i try to change in app\design\frontend\rwd\default\template\catalog\product\compare\list.phtml but no chance there.. still not touch core files Commented Jul 21, 2015 at 7:35
  • Make sure you flush the cache
    – lloiacono
    Commented Jul 21, 2015 at 7:42
  • Also as far as I know, rwd is part of magento core files (devdocs.magento.com/guides/m1x/ce19-ee114/RWD_dev-guide.html) so you should try to create your own version of this file
    – lloiacono
    Commented Jul 21, 2015 at 7:45
  • Deleted folder Cache from var, also disable all caches from admin. Commented Jul 21, 2015 at 8:40
  • it's done.. If want to do then just change code in "This file can be found here:/app/design/frontend/default/[theme name]/template/catalog/product/view/attribute.phtml" Commented Mar 18, 2016 at 6:31
-1

We have add done this in the list.phtml and is working fine:

New line 93
<?php if (!is_null($_item->getData($_attribute->getAttributeCode())) && ((string)$_attribute->getFrontend()->getValue($_item) != '')): ?>
New line 120
<?php endif; ?>

If one of all compared product have something inside the attribute, the line while appear, but you can change "no" in mage_catalog.csv and add "N/A"

Work with Magento 1.9 to 1.9.2.4

1
  • I would not recommend this. You're only taking into account the one product. For example lets say product A has colour attribute empty and colour B has the colour attribute set. Aren't you supposed to still compare both attributes? Also you need to take into account the product attribute label. Commented Jan 3, 2017 at 16:23

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