Home » Magento

Magento: Get current and parent category

22 December 2009 5,539 views Popularity: 12% Share/Bookmark

email

You can get current category from the following code:

$currentCategory = Mage::registry('current_category');

You can get the parent category from the following code:

/**
 * You want the parent category of a sub-category
 * Let the sub-category be $subCategory
 */

$parentCategory = Mage::getModel('catalog/category')->load($subCategory->getParentId());

Related posts:

  1. Magento: Get category name and url from product
  2. Magento: How to filter product collection using 2 or more category filters?
  3. Magento 1.4: No products displayed in category listing
  4. Magento: Get Bestselling products by category and date time
  5. Magento: Adding category attributes
  6. Magento: Get parent id of simple product associated to configurable product
  7. Magento: Get sub categories and product count
  8. Magento: Convert Price from Current Currency to Base Currency and vice-versa
  9. Magento: Get current Url of the page
  10. How to show child page (sub page) list in parent page in wordpress?
  • Vishalsanwar

    HI,

    How to  Get current and parent category in a colllection in admin section ???

    Thanx
    Vishal