QuestionsHow to get all parent category name using category id?
mmvictormacclien asked 11 months ago

I want all parent category name using category Id

  • Main Category
    • Sub Category 1
      • Sub Category 3
      • Sub Category 4
    • Sub Category 2
      • Sub Category 5
      • Sub Category 6

Now I have id of this category Sub Category 6 Now, i want this two name Sub Category 2,Main Category in frontend.
 How to get all parent category name?

1 Answers
mmWebetutorial Staff answered 11 months ago

You can find parent category name by following method:-
$category = Mage::getModel(‘catalog/category’)->load($categoryId());

$names = array(); foreach ($category->getParentCategories() as $parent) {

$names[] = $parent->getName();

}

//here you will find `$names` in array

Your Answer
Login
Enter email and password to comment or answer
Not the answer you are looking for? Browse other questions tagged or ask your own question.