I want to display the list of all category into which the particular product belongs .This information is neede to display all category in product view page.

  • simply the product category levels right? getCategoryIds() list all category ids for a product. Nov 21 '14 at 8:58

The following code belongs in app/design/frontend/your_theme/default/template/catalog/product/view.phtml:

$category_ids = $_product->getCategoryIds();
foreach ($category_ids as $category_id) {
    $category = Mage::getModel('catalog/category')->load($category_id) ;
    echo $category->getName() . "<br/>";
  • 1
    Will it list all categories? Nov 21 '14 at 5:50
  • Yes. In future try and test the code before you decide to post comment questions.
    – Moose
    Nov 21 '14 at 6:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.