Magento get Category and Sub category details
When you are customize the magento site you may be want to get current category,root category and sub category details like category ID,name,…etc.Here is a simple example.
// Load libraries $layer = Mage::getSingleton('catalog/layer'); $_category = $layer->getCurrentCategory(); // Get Current category ID $currentCategoryId = $_category->getId(); //Get current category all details $current_category = Mage::registry('current_category'); // Get Parent category ID of the current category like root category $parent_id = $current_category->parent_id;
If you want to load known category details ,for a example want to load category id=10, details.That is like this.
$_category = Mage::getModel('catalog/category')->load(10); // category ID=10 echo $_category->getUrl(); // get category URL echo $_category->getUrlKey(); // get category URL Key echo $_category->getName(); // get category Name
What's your reaction?
Excited
0
Happy
0
In Love
0
Not Sure
0
Silly
0