Magento Forum

   
Page 1 of 3
Magento 1.5 Admin - categories tree for products does not auto-expand to show product categories
 
iamcortez
Jr. Member
 
Total Posts:  27
Joined:  2010-05-28
 

Hi,

I just installed a clean Magento 1.5 as I was having the same issue described in the subject on an upgrade I did, but the issue is the same on a clean install.

I created some categories & sub-categories, then created a product and assigned it to one of the sub-categories.  When I go back to view the product in Admin & look at the categories tab, the tree is collapsed - it only shows the top level categories.  This worked fine on 1.4.1.0 & correctly auto-expanded to show me the categories the product is assigned to.

Has anybody else experienced this issue?

Thanks

Steve

 
Magento Community Magento Community
Magento Community
Magento Community
 
erikaugustin
Jr. Member
 
Total Posts:  24
Joined:  2010-01-18
 

Same problem here?

No solution available yet?

Thks
Erik

 
Magento Community Magento Community
Magento Community
Magento Community
 
erikaugustin
Jr. Member
 
Total Posts:  24
Joined:  2010-01-18
 

After a reindex the menus showed as needed.

So solved

 
Magento Community Magento Community
Magento Community
Magento Community
 
rrroulio
Sr. Member
 
Avatar
Total Posts:  88
Joined:  2008-03-26
france moselle
 

I have similar pb in all my websites in 1.5
one function is different from 1.4.2 and 1.5 in :
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Categories.php

i have changed it by the 1.4.2 code and yeahh; it works fine. Categories are auto expanded

change the last fonction by this code.

public function getSelectedCategoriesPathIds($rootId false)
    
{
        $ids 
= array();
        
$collection Mage::getModel('catalog/category')->getCollection()
            ->
addFieldToFilter('entity_id', array('in'=>$this->getCategoryIds()));
        foreach (
$collection as $item{
            
if ($rootId && !in_array($rootId$item->getPathIds())) {
                
continue;
            
}
            
foreach ($item->getPathIds() as $id{
                
if (!in_array($id$ids)) {
                    $ids[] 
$id;
                
}
            }
        }
        
return $ids;
    
}

 
Magento Community Magento Community
Magento Community
Magento Community
 
Beddinggirl
Jr. Member
 
Total Posts:  11
Joined:  2011-03-02
 

I have the code posted above in my Magento 1.3.3 install, and I have refreshed and rebuilt everything in the cache, but I still can’t expand my category tree.  What could be causing this?

 
Magento Community Magento Community
Magento Community
Magento Community
 
rrroulio
Sr. Member
 
Avatar
Total Posts:  88
Joined:  2008-03-26
france moselle
 

the problem become with 1.5 version, never with previous. I think your problem is a javascript conflict with another plug in used in admin panel. look at the html code of the page and see external js used. Try to desactivate extensions whitch use external js and refresh cache.

 
Magento Community Magento Community
Magento Community
Magento Community
 
mattclegg
Jr. Member
 
Total Posts:  5
Joined:  2010-05-26
 

I had patched Magento 1.5.0.1 with the above -but now the problem has started again.

Some categories do not appear. If remove the above patch then even less categories appear.

Is this fixed in Magento 1.6 ?

 
Magento Community Magento Community
Magento Community
Magento Community
 
JelmoNL
Jr. Member
 
Total Posts:  2
Joined:  2011-05-24
 

I had a similar problem, when editing/creating a product I couldn\’t expand the root-categories.
It turned out it was a Prototype version-problem, during development I upgraded to the newest version of Prototype.js since I had strange errors which were fixed by upgrading. Little did I know I was sinking even further under water… After downgrading again (backups people, backups) expanding worked fine. I also applied Jemoon\’s fix suggested in this thread which is worth a read: http://www.magentocommerce.com/boards/viewthread/27032/P45/#t90240

Cheers,
Jelmer

 
Magento Community Magento Community
Magento Community
Magento Community
 
dlefers
Jr. Member
 
Avatar
Total Posts:  1
Joined:  2011-06-13
Deventer, The Netherlands
 

Just discovered this bug when i was attended to it by one of my clients.

The problem does not seem to be PHP related. Since the Ajax call is returning the correct JSON response for the parents subcategories. Simple conclusion is that is has something to do with the related javascript parsing all the subcategories in the tree.

I`m not sure why but i got the solution for my case:

Open:

app/design/adminhtml/default/default/template/catalog/product/edit/categories.phtml

Search for the instantiation of the new TreePanel around line: 65.

In the settings, set animate:true to animate:false. Find the example attached below:

var tree = new Ext.tree.TreePanel('product-categories'{
        animate
:false,
        
loadercategoryLoader,
        
enableDD:false,
        
containerScrolltrue,
        
rootUIProviderExt.tree.CheckboxNodeUI,
        
selModel: new Ext.tree.CheckNodeMultiSelectionModel(),
        
rootVisible'<?php echo $this->getRootNode()->getIsVisible() ?>'
    
});

Clear the Admin cache files, reload the product edit page and go to the categories tab, thats it!

Anyone has a clue what is causing the setting “animate” to not parse any childnodes?

 
Magento Community Magento Community
Magento Community
Magento Community
 
mattclegg
Jr. Member
 
Total Posts:  5
Joined:  2010-05-26
 

Welcome dlefers,

The problem for me is PHP based as the first view of sub categories (childnodes) is incorrect when loading the categories tab. No AJAX / JSON request is made for subcategories that are already loaded so changing the JS made no difference.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Remz-Jay
Jr. Member
 
Total Posts:  7
Joined:  2009-04-23
 

Awesome! Works like a charm indeed. Thanks for your find, saved me tons of trouble!

rrroulio - 16 April 2011 05:41 PM

I have similar pb in all my websites in 1.5
one function is different from 1.4.2 and 1.5 in :
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Categories.php

i have changed it by the 1.4.2 code and yeahh; it works fine. Categories are auto expanded

 
Magento Community Magento Community
Magento Community
Magento Community
 
djiuzd
Jr. Member
 
Total Posts:  2
Joined:  2011-02-15
 

For me this problem started after turning on the merging of javascript files. After I turned it of, the problem disappeared. Shame, because I keep running into problems after merging css and/or javascript files, while the merging has a positive effect on my page speed..

 
Magento Community Magento Community
Magento Community
Magento Community
 
SonicE
Member
 
Avatar
Total Posts:  47
Joined:  2007-11-08
Bulgaria
 

I think the issue is in another function in app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Categories.php

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;
            
}

            $ids 
$this->getSelectedCategoriesPathIds($rootId);
            
$tree Mage::getResourceSingleton('catalog/category_tree')
                ->
loadByIds($idsfalsefalse);

            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);
                if (
$this->isReadonly()) {
                    $root
->setDisabled(true);
                
}
            }
            
elseif($root && $root->getId() == Mage_Catalog_Model_Category::TREE_ROOT_ID{
                $root
->setName(Mage::helper('catalog')->__('Root'));
            
}

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

        
return $root;
    
}

Take a look at

$storeId = (int) $this->getRequest()->getParam('store');

On a single store view it always returns NULL and then the $rootId is not set correctly by calling getSelectedCategoriesPathIdss($rootId)

My fix is:

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');
//------>START FIX
            
if ($storeId{
                $store 
Mage::app()->getStore($storeId);
                
$rootId $store->getRootCategoryId();
                
$ids $this->getSelectedCategoriesPathIds($rootId); // Added this line, and commented below
            
}
            
else {
                $rootId 
Mage_Catalog_Model_Category::TREE_ROOT_ID;
                
$ids $this->getSelectedCategoriesPathIds(); // Added this line without passing $rootId , and commented below
            
}

            
//$ids = $this->getSelectedCategoriesPathIds($rootId); //Commented this line and moved up
//------>END FIX         
            
$tree Mage::getResourceSingleton('catalog/category_tree')
                ->
loadByIds($idsfalsefalse);

            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);
                if (
$this->isReadonly()) {
                    $root
->setDisabled(true);
                
}
            }
            
elseif($root && $root->getId() == Mage_Catalog_Model_Category::TREE_ROOT_ID{
                $root
->setName(Mage::helper('catalog')->__('Root'));
            
}

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

        
return $root;
    
}

Please correct me if all this is wrong

 
Magento Community Magento Community
Magento Community
Magento Community
 
LoriKB
Jr. Member
 
Total Posts:  7
Joined:  2011-04-08
 

I am having this same issue on the category edit page (not the products category tab)

Anyone else having this issue here? I will select expand and nothing will happen but if I then hit refresh the sub categories are there.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Wyomind
Jr. Member
 
Avatar
Total Posts:  26
Joined:  2010-11-09
 

Hi there,

Here is how I Fixed the issues.

In app\design\adminhtml\default\default\template\catalog\product\edit\categories.phtml
I changed the event observer “on load” (line 60) to this

categoryLoader.on("load", function(treeLoadernodeconfig{
        varienWindowOnload
();
        
node.childNodes.each(function(e){
          
if($('product_categories').value.split(',').indexOf(e.attributes.id)!=-1)
            
e.getUI().check(true);
        
})
    
});

Regards.

 
Magento Community Magento Community
Magento Community
Magento Community
 
benz001
Sr. Member
 
Avatar
Total Posts:  238
Joined:  2009-02-05
Sydney
 

Unfortunately this javascript patch misses the case when a child category is selected but it’s parent category isn’t
SonicE’s php mods above have been working for me across multi layered category structures with skipped categories and looks like the right fix.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
Page 1 of 3