- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2017
11:02 PM
04-03-2017
11:02 PM
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; ?>
Solved! Go to Solution.
Labels:
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2017
11:40 PM
04-03-2017
11:40 PM
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
Problem solved? Click Accept as Solution!"
Qaisar Satti
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2017
11:40 PM
04-03-2017
11:40 PM
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
Problem solved? Click Accept as Solution!"
Qaisar Satti
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2017
11:45 AM
04-11-2017
11:45 AM
Re: Custom Attribute on Category Page
This helped! Thank you!