Magento Forum

   
Category problem after upgrade to 1.1.7
 
QuattroPorte
Jr. Member
 
Avatar
Total Posts:  19
Joined:  2008-03-08
 

After upgrading to 1.1.7, I’m experiencing an issue where the previously defined categories no longer show up in the admin panel and I’m getting the infamous “Undefined class constant ‘TREE_ROOT_ID’” error.
The categories also don’t show up when editing/viewing a product (same error, needless to say)

I have done everything I can think of to clean up the installation:
- Cleared out all the download cache
- Reinstalled every single module (magento connect)
- Overwritten all the files with those from the 1.1.7 tarball
- added the line “const TREE_ROOT_ID = 1;” to class Mage_Adminhtml_Block_Catalog_Category_Abstract

The categories show up just fine in the front end, so what gives??
I’m attaching screen caps for all it’s worth.

Image Attachments
AdminNoCategories.gifAdminProductNoCategories.gif
 
Magento Community Magento Community
Magento Community
Magento Community
 
QuattroPorte
Jr. Member
 
Avatar
Total Posts:  19
Joined:  2008-03-08
 
QuattroPorte - 21 November 2008 07:20 AM

After upgrading to 1.1.7, I’m experiencing an issue where the previously defined categories no longer show up in the admin panel and I’m getting the infamous “Undefined class constant ‘TREE_ROOT_ID’” error.
The categories also don’t show up when editing/viewing a product (same error, needless to say)

I have done everything I can think of to clean up the installation:
- Cleared out all the download cache
- Reinstalled every single module (magento connect)
- Overwritten all the files with those from the 1.1.7 tarball
- added the line “const TREE_ROOT_ID = 1;” to class Mage_Adminhtml_Block_Catalog_Category_Abstract

The categories show up just fine in the front end, so what gives??
I’m attaching screen caps for all it’s worth.

Since I got no response on this, I “fixed” the issue myself.
For all it’s worth:
Since the value of ‘const TREE_ROOT_ID’ appears to never be anything other than 1, I hacked the app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php and replaced all incidences of the call to ‘Mage_Catalog_Model_Category::TREE_ROOT_ID” with ‘1’.
Presto, bingo, my categories are showing up again.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Ana Bahr
Member
 
Total Posts:  33
Joined:  2009-03-05
 

Hello QuattroPorte!

I’m haveing same problem here.

Could u explain me better what I need to replace in my Abstract.php file?

Right now it is like this:

<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category   Mage
 * @package    Mage_Adminhtml
 * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */

/**
 * Category abstract block
 *
 * @category   Mage
 * @package    Mage_Adminhtml
 * @author     Magento Core Team <core@magentocommerce.com>
 */
class Mage_Adminhtml_Block_Catalog_Category_Abstract extends Mage_Adminhtml_Block_Template
{

    
public function __construct()
    
{
        parent
::__construct();
    
}

    
public function getCategory()
    
{
        
return Mage::registry('category');
    
}

    
public function getCategoryId()
    
{
        
if ($this->getCategory()) {
            
return $this->getCategory()->getId();
        
}
        
return Mage_Catalog_Model_Category::TREE_ROOT_ID;
    
}

    
public function getCategoryName()
    
{
        
return $this->getCategory()->getName();
    
}

    
public function getCategoryPath()
    
{
        
if ($this->getCategory()) {
            
return $this->getCategory()->getPath();
        
}
        
return Mage_Catalog_Model_Category::TREE_ROOT_ID;
    
}

    
public function hasStoreRootCategory()
    
{
        $root 
$this->getRoot();
        if (
$root && $root->getId()) {
            
return true;
        
}
        
return false;
    
}

    
public function getStore()
    
{
        $storeId 
= (int) $this->getRequest()->getParam('store');
        return 
Mage::app()->getStore($storeId);
    
}

    
public function getRoot($parentNodeCategory=null$recursionLevel=3)
    
{
        
if (!is_null($parentNodeCategory) && $parentNodeCategory->getId()) {
            
return $this->getNode($parentNodeCategory$recursionLevel);
        
}
        $root 
Mage::registry('root');
        if (
is_null($root)) {
            $storeId 
= (int) $this->getRequest()->getParam('store');

            if (
$storeId{
                $store 
Mage::app()->getStore($storeId);
                
$rootId $store->getRootCategoryId();
            
}
            
else {
                $rootId 
Mage_Catalog_Model_Category::TREE_ROOT_ID;
            
}

            $tree 
Mage::getResourceSingleton('catalog/category_tree')
                ->
load($rootId$recursionLevel);

            if (
$this->getCategory()) {
                $tree
->loadEnsuredNodes($this->getCategory(), $tree->getNodeById($rootId));
            
}

            $tree
->addCollectionData($this->getCategoryCollection());

            
$root $tree->getNodeById($rootId);

            if (
$root && $rootId != Mage_Catalog_Model_Category::TREE_ROOT_ID{
                $root
->setIsVisible(true);
            
}
            
elseif($root && $root->getId() == Mage_Catalog_Model_Category::TREE_ROOT_ID{
                $root
->setName(Mage::helper('catalog')->__('Root'));
            
}

            Mage
::register('root'$root);
        
}

        
return $root;
    
}

    
/**
     * Get and register categories root by specified categories IDs
     *
     * IDs can be arbitrary set of any categories ids.
     * Tree with minimal required nodes (all parents and neighbours) will be built.
     * If ids are empty, default tree with depth = 2 will be returned.
     *
     * @param array $ids
     */
    
public function getRootByIds($ids)
    
{
        $root 
Mage::registry('root');
        if (
null === $root{
            $tree 
Mage::getResourceSingleton('catalog/category_tree')
                ->
loadByIds($ids);
            
$rootId Mage_Catalog_Model_Category::TREE_ROOT_ID;
            
$root   $tree->getNodeById($rootId);
            if (
$root && $rootId != Mage_Catalog_Model_Category::TREE_ROOT_ID{
                $root
->setIsVisible(true);
            
}
            
elseif($root && $root->getId() == Mage_Catalog_Model_Category::TREE_ROOT_ID{
                $root
->setName(Mage::helper('catalog')->__('Root'));
            
}
            Mage
::register('root'$root);
        
}
        
return $root;
    
}

    
public function getNode($parentNodeCategory$recursionLevel=2)
    
{
        $tree 
Mage::getResourceModel('catalog/category_tree');

        
$nodeId     $parentNodeCategory->getId();
        
$parentId   $parentNodeCategory->getParentId();

        
$node $tree->loadNode($nodeId);
        
$node->loadChildren($recursionLevel);

        if (
$node && $nodeId != Mage_Catalog_Model_Category::TREE_ROOT_ID{
            $node
->setIsVisible(true);
        
elseif($node && $node->getId() == Mage_Catalog_Model_Category::TREE_ROOT_ID{
            $node
->setName(Mage::helper('catalog')->__('Root'));
        
}

        $tree
->addCollectionData($this->getCategoryCollection());

        return 
$node;
    
}

    
public function getSaveUrl(array $args = array())
    
{
        $params 
= array('_current'=>true);
        
$params array_merge($params$args);
        return 
$this->getUrl('*/*/save'$params);
    
}

    
public function getEditUrl()
    
{
        
return $this->getUrl("*/catalog_category/edit", array('_current'=>true'store'=>null'_query'=>false'id'=>null'parent'=>null));
    
}
}

I would appreciate your help!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top