在magento中创建新类别时如何获取父类别id?

在magento中创建新类别时如何获取父类别id?,magento,Magento,我只是在Magento自定义扩展上工作,这是当我创建属于特定类别的新类别时,比如说“附件”。然后我想让它显示这个功能,否则我不想让它可见。在编辑中编辑类别没有问题,我可以通过Mage::registry('current_category')->getParentCategory()->getId()获取父类别但在创建新类别时无法获取父id 请给我最好的解决方案 请试试这个 <?php $_categories = Mage::getModel('catalog/categor

我只是在Magento自定义扩展上工作,这是当我创建属于特定类别的新类别时,比如说“附件”。然后我想让它显示这个功能,否则我不想让它可见。在编辑中编辑类别没有问题,我可以通过
Mage::registry('current_category')->getParentCategory()->getId()获取父类别但在创建新类别时无法获取父id

请给我最好的解决方案

请试试这个

<?php
      $_categories = Mage::getModel('catalog/category')
                ->getCollection()
                ->addAttributeToSelect('*')
                ->addAttributeToFilter('level',3);
   // $_categories = $_helper->getStoreCategories();
        if (count($_categories) > 0){
            foreach($_categories as $_category){
                $parentId=Mage::getModel('catalog/category')->load($_category->getId())->getParentId();
                echo $parentId;
            }
        }
?>


您可以根据需要更改级别。让我知道这是否对您有帮助。

您想从产品中获取父类别id吗?不,我想在创建新子类别时获取父类别id(管理类别->添加子类别)