search
top

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



7 Responses to “Category Name Magento”

  1. Mitesh says:

    Thanks great job done by you

  2. Caedmon says:

    This returns everything except the imageUrl for me… any ideas why?

  3. Thanks great job done by you. After investing whole day i got the solution. Thanks againg

    Praveen

  4. Thanks a lot overall i got the solution after investing all day. thanks again

  5. How to get caterory id from category name in magento.

    I know the category name. I have to fetch it’s id and subcategories.

    Please help

    • DWRoot says:

      @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

top