Magento – Put Category-IDs into category tree in backend

To show the category IDs in the category tree under Catalog->Categories->Manage Categories you can rewrite Mage_Adminhtml_Block_Catalog_Category_Tree in an own module. You have to rewrite the method buildNodeName like this:

/**
 * Get category name
 *
 * @param Varien_Object $node
 * @return string
 */
public function buildNodeName($node)
{
    $result = $this->escapeHtml($node->getName());
    if ($this->_withProductCount) {
        $result .= ' (' . $node->getProductCount() . ')'. ' [' . $node -> getId() . ']';
        #Alternative:  $result .= ' [' . $node -> getId() . '] (' . $node->getProductCount() . ')';
        #Alternative: $result = "[{$node -> getId()}] {$this->escapeHtml($node->getName())} ({$node->getProductCount()})";
    }
    return $result;
}

The important part is  . ‘ [‘ . $node -> getId() . ‘]’  in line eleven.

Leave a Reply

Your email address will not be published.

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.