so I am not sure how to debug this. I can pull all information from a category but I cannot get the 'description' attribute to pull through. It just appears blank.

This doesn't work:

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

<?php if($_description=$this->getCurrentCategory()->getDescription()): ?>
    <div class="category-description std">
        <?php echo $_helper->categoryAttribute($_category, $_description, 'description') ?>
<?php endif; ?>

Or this:

echo $_category->getData('description');

However getName, url, getting the image, or even the custom thumbnail works but just not text fields, all other attributes I can call. I am not sure if there is a setting I am missing or something else is happening.

Any ideas?

  • You have mutiple store view/ – Amit Bera Jun 18 '15 at 10:22
  • Nope each Website has 1 view. – Francis Jun 18 '15 at 10:47

I actually debugged it myself, as I was sure it was supposed to work.

BUT it didn't. And I traced it was because the description field was EMPTY. I filled the description field with some random text and it worked.

Modify this:

<?php if($_description=$this->getCurrentCategory()->getDescription()): ?>
<div class="category-description std">
    <?php echo $_helper->categoryAttribute($_category, $_description, 'description') ?>

to this:

<div class="category-description std">
    // You can put this line above, after the $_category variable for cleaner code.
    echo ($_description) ? $_description ? "No description..."; // Or simply ''
  • This would only work if my description was actually blank. It isn't, it has text in it and still shows as blank. – Francis Jun 18 '15 at 10:46
  • That didn't go as expected... Maybe the description attribute was removed or something.. Why don't you try to debug it? Go to Mage_Eav_Model_Entity_Abstract class, _loadModelAttributes() method. Breakpoint at line $select = $this->_prepareLoadSelect($selects); and get the query of that select. Copy that and manually edit the query and join it in eav_attribute table so you can see if the description attribute is in it. – Vernard Luz Jun 18 '15 at 12:37
  • The attribute exists and doesnt get missed out I can see it's existance and what I have entered into it. I'm thinking it must be a setting somewhere that is not allowing the attribute to pull to the frontend. – Francis Jun 18 '15 at 14:31
  • Of course it exists, what you need to check if the attribute description is pulled from database. – Vernard Luz Jun 18 '15 at 16:07

The following worked for me :

echo Mage::getModel('catalog/layer')->getCurrentCategory()->getDescription(); 

or you can load the category collection like this :

$cat = Mage::getModel('catalog/category')->load($_category->getId());
$description = $cat->getDescription();
  • Niether of those work for me, it should work, as getName still functions with them. – Francis Jun 18 '15 at 9:45
  • Where are you writing this piece of code? – Manashvi Birla Jun 18 '15 at 9:46
  • Within the Category View. The default code doesn't even work. But it isn't erroring out, just simply believes all descriptions are null or "". – Francis Jun 18 '15 at 9:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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