Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Trying to show only categories and sub-categories assigned to a store
 
Emperor
Sr. Member
 
Total Posts:  111
Joined:  2007-08-31
 

When a store is created under a website, a root category has to be selected.

When a user is creating a product for a website, I want to show the categories and sub-categories for the assigned categories to the respective stores in the website.

I am trying to edit : Adminhtm\Block\Catalog\Product\Edit\Tab\Categories.php to give me that result but to not a lot of success.

I have been edit the getRoot() function. I have tested it out with one store id, which loads that category alone, but if a subcategory is also a root category and you click to expand the sub category it doesn’t work.

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 
1;
            
          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);
            
//$root = $tree->getNodeById(2);

            
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;
    
}
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top