Category Name Magento

Hello all,

I am writing here the code for getting category information of the known category id.

<?php 
    
	$catagory_model = Mage::getModel('catalog/category');
	$categories = $catagory_model->load($id); // where $id will be the known category id 
	if(!empty($categories))
	{
	    echo 'category name->'.$categories->getName(); //get category name	    		
	    echo 'category image url->'.$categories->getImageUrl(); //get category image url
	    echo 'category url path->'.$categories->getUrlPath(); //get category url path
	      
	}   
?> 

Hope this is helpful

9 thoughts on “Category Name Magento

    1. @Dipannita –
      Suppose name of the category is ‘Magento’ (excluding quotes).
      So for getting category id you need to use this code

      //get category model
      $category_model = 
      Mage::getModel('catalog/category')->loadByAttribute('name','Magento'); 
      echo 'Category ID -> '.$category_model->getId(); //get category id
      

      For sub categories refer this post of mine – http://blog.decryptweb.com/child-categories-magento/
      Hope this helps you.

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top