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

How do I find out what is the category ID
 
davidgrun
Sr. Member
 
Total Posts:  245
Joined:  2008-07-10
 

Is there a fast and easy way to see what is a category ID without having to go into PHPmyAdmin??

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
sherrie
Moderator
 
Avatar
Total Posts:  1655
Joined:  2007-12-14
Waterloo, ON
 

Well, I wouldn’t call it fast - but you can go to the admin, Catalog > Manage Categories and click on the category you want to know the ID of.

 
Magento Community Magento Community
Magento Community
Magento Community
 
nikefido
Guru
 
Avatar
Total Posts:  481
Joined:  2008-07-11
New Haven, CT
 

Sometimes the product URL will have the category in it.

otherwise, perhaps some of these code snippets will help if you are doing some programming:

$currentcat$this->getCurrentCategory()->getID(); 
/************************************************************************/
$_categories $product->getCategoryIds();
/************************************************************************/
$category    Mage::getModel('catalog/category')->load(4); //category id of 4
/************************************************************************/
public function getCurrentCategory()
    
{
        $_currentCategory 
Mage::registry('current_category');
        
        
//START  EDIT
        
if (isset($_currentCategory)){
            
return Mage::registry('current_category');
        
else 
            $categoryId 
Mage::getSingleton('core/store')->getConfig('catalog/category/root_id');
            
$category Mage::getModel('catalog/category')->load($categoryId);
            
Mage::register('current_category'$category);
            
            return 
Mage::registry('current_category');
        
}
        
//END EDIT
    

/************************************************************************/
$_categories $_product->getCategoryIds();
$_category Mage::getModel('catalog/category')->load($_categories[0]);
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top