Thursday 20 October 2011

Magento 1.5 admin - Categories are not appearing when editing products

I have similar pb in all my websites in 1.5 
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 function 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;
    }

No comments:

Post a Comment