I've realised there are many answer which actually are technically incorrect because they only are taking into account one product. They remove any attribute that is empty or null even if the second product's attribute is not null or empty.

So I decided to post an answer.

  • In what folder I can find this block and function?
    – 2feyrr
    Oct 15, 2018 at 10:53
  • @RamaChandranM this is the question. Not an answer. Oct 15, 2018 at 16:27
  • I am sorry mistake added comments for thsi :( i will remove it Oct 15, 2018 at 16:58
  • How do we implement the accepted answer?
    – HRR1337
    May 17, 2019 at 13:01
  • @HRR1337 following it? May 17, 2019 at 14:35

1 Answer 1


We need to override the block class Mage_Catalog_Block_Product_Compare_List and function getAttributes(), this way we have pre sorted array list of attributes instead of having to do the changes at template level.

public function getAttributes()
  if (is_null($this->_attributes)) {
     $this->_attributes = $this->getItems()->getComparableAttributes();

  // Remove Null Attribute From Compare List
  foreach($this->_attributes as $attribute) {
     $size  = sizeof($this->getItems());
     $count = 0;

     foreach($this->getItems() as $item) {
        $itemAttribute = $item->getData($attribute->getName());
        $trimAttribute = trim($itemAttribute);
        if(is_null($itemAttribute) || empty($trimAttribute)) {

        if($count == $size) {

  return $this->_attributes;


Your Answer

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

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