cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Attribute on Category Page

SOLVED
   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

Custom Attribute on Category Page

I'm trying to display a custom attribute on the category page. It works fine but when customer uses the search field, it displays the error "Fatal error: Call to a member function getId() on a non-object". My code is below. Any help is greatly appreciated.

 

$_category = Mage::registry('current_category');
<?php if ($_category->getId() && $_category->getCustomAttribute()): ?>
        <div>
            <?php echo $_helper->categoryAttribute($_category, $_category->getCustomAttribute(), 'custom_attribute') ?>
        </div>
    <?php endif; ?>
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Custom Attribute on Category Page

Try this code because this code is causing the errors  $_category->getId()

$_category = Mage::registry('current_category');
<?php if (Mage::registry('current_category')): ?>
        <div>
            <?php echo $_helper->categoryAttribute($_category, $_category->getCustomAttribute(), 'custom_attribute') ?>
        </div>
    <?php endif; ?>

 

Find helpful ? Consider Giving Kudos to this post.
Problem solved? Click Accept as Solution!"
Qaisar Satti

View solution in original post

2 REPLIES 2

Re: Custom Attribute on Category Page

Try this code because this code is causing the errors  $_category->getId()

$_category = Mage::registry('current_category');
<?php if (Mage::registry('current_category')): ?>
        <div>
            <?php echo $_helper->categoryAttribute($_category, $_category->getCustomAttribute(), 'custom_attribute') ?>
        </div>
    <?php endif; ?>

 

Find helpful ? Consider Giving Kudos to this post.
Problem solved? Click Accept as Solution!"
Qaisar Satti

Re: Custom Attribute on Category Page

This helped! Thank you!