Get all categories in magento1
$categories = Mage::getModel('catalog/category')->getCollection() ->addAttributeToSelect('id') ->addAttributeToSelect('name') ->addAttributeToSelect('url') ->addAttributeToSelect('is_active'); foreach ($categories as $category) { if ($category->getIsActive()) { // Only pull Active categories $entity_id = $category->getId(); $name = $category->getName(); $url_key = $category->getUrlKey(); $url_path = $category->getUrl(); } }
Get the child category of the category in magento1
$children = Mage::getModel('catalog/category')->getCategories(category_id); foreach ($children as $category) { echo $category->getName(); echo $category->getImageUrl(); echo $category->getDescription(); echo $category->getId(); }
Note:- category_id like 1,2 etc.
Get all categories of the product in magento1
$_Product = Mage::getModel("catalog/product")->load(Product_id); $categoryIds = $_Product->getCategoryIds();//array of product categories foreach($categoryIds as $categoryId) { $category = Mage::getModel('catalog/category')->load($categoryId); echo $category->getName(); echo $category->getImageUrl(); echo $category->getDescription(); echo $category->getId(); }
Note:- put product id in the load function.
Get the level of the category in magento1
$category = Mage::getModel('catalog/category')->load(category_id); echo $category->getLevel();
Note:- put the category id in the load function.
Get the category name, image, description from category id in magento1
$category = Mage::getModel('catalog/category')->load(category_id); echo $category->getName(); echo $category->getImageUrl(); echo $category->getDescription();
Note:- put the categoryid in the load function.