Magento Resource | E-Commerce Generation Explorer

Oct/10

17

How to add category description under category

Here is the example:
You can see the example of this menu at http://www.cortevents.com, under furniture catalog. On a left hand side each category item has small text that is being pulled from category description field.

STEP1:
/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Category/Tree.php
I’ve inserted following code on the line 234 (_getDefaultCollection function, after addAttributeToSelect(‘name’))

1
->addAttributeToSelect('description')


STEP2:
/app/code/core/Mage/Catalog/Model/Category.php
I’ve added the following function at the end of the class

1
2
3
public function getDescription() {
    return $this->_getData('description');
}

STEP3:
/app/code/core/Mage/Catalog/Block/Navigation.php
I’ve added the following code on line 177

1
2
3
if ($level == 0) {
    $html .= '<span class="category-desc">'.$category->getDescription().'</span>';
}

OK, We done it.

From:http://www.igorkrasnykh.com

3 comments

  • JRM · 29/10/2010 at 15:38

    Hello,
    First of all congratulations for the tutorial.
    But I think there must be errors in the description …

    I tried to implement and does not work.
    I also noticed that the “lines” eg 177 are not right.

    Regards

  • Admin comment by leo · 13/12/2010 at 15:45

    Could you tell me which magento version you using?

  • taha azzabi · 03/10/2011 at 23:29

    hello we make that more easy:
    just we call:
    $layer = Mage::getSingleton(“catalog/layer”);
    $_category = $layer->getCurrentCategory();
    var_dump($_category->getDescription());

Leave a Reply

<<

>>

Theme Design by devolux.nh2.me