Magento Category Tree is Not Showing In Product Edit (Backend)

Today i got very strange problem in my client’s Magento set up…
When i have open products in edit mode in Magento 1.5 Admin then categories tree for product does not expand to show product sub-categories… Only Root categories were visible…
I couldn’t find proper solution for this problem… But i did patch which worked perfectly for me. Hope this will help to someone else too…
Solution:
There is some change in Categories.php file of magento 1.4.2 and 1.5.x
So,i have backed up old Categories.php in:
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Categories.php
i have changed 1.5 store code by the 1.4.2 code and yeahh; it works fine. Categories are auto expanded
Change the last fonction by below code in file which you are going to replace.
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; }

I hope this will work for you. Do comment me if you have any problem.. Good Luck!

Comments

Popular Posts

Magmi Single and Multiple Category Importer