Get all categories in magento1
[php]
$categories = Mage::getModel(‘catalog/category’)->getCollection()
->addAttributeToSelect(‘id’)
->addAttributeToSelect(‘name’)
->addAttributeToSelect(‘url’)
->addAttributeToSelect(‘is_active’);
$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();
}
}
[/php]
Get the child category of the category in magento1
[php]
$children = Mage::getModel(‘catalog/category’)->getCategories(category_id);
foreach ($children as $category) {
echo $category->getName();
echo $category->getImageUrl();
echo $category->getDescription();
echo $category->getId();
}
$children = Mage::getModel(‘catalog/category’)->getCategories(category_id);
foreach ($children as $category) {
echo $category->getName();
echo $category->getImageUrl();
echo $category->getDescription();
echo $category->getId();
}
[/php]
Note:- category_id like 1,2 etc.
Get all categories of the product in magento1
[php]
$_Product = Mage::getModel("catalog/product")->load(Product_id);
$categoryIds = $_Product->getCategoryIds();//array of product categories
$_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();
}
[/php]
Note:- put product id in the load function.
Get the level of the category in magento1
[php]
$category = Mage::getModel(‘catalog/category’)->load(category_id);
echo $category->getLevel();
[/php]
$category = Mage::getModel(‘catalog/category’)->load(category_id);
echo $category->getLevel();
[/php]
Note:- put the category id in the load function.
Get the category name, image, description from category id in magento1
[php]
$category = Mage::getModel(‘catalog/category’)->load(category_id);
echo $category->getName();
echo $category->getImageUrl();
echo $category->getDescription();
[/php]
$category = Mage::getModel(‘catalog/category’)->load(category_id);
echo $category->getName();
echo $category->getImageUrl();
echo $category->getDescription();
[/php]
Note:- put the categoryid in the load function.