Just another WordPress.com weblog

<?php
require_once ‘app/Mage.php’;
Mage::app();
$category = Mage::getModel(‘catalog/category’);
$tree = $category->getTreeModel();
$tree->load();
$ids = $tree->getCollection()->getAllIds();
$arr = array();
if ($ids):
foreach ($ids as $id){
$cat = Mage::getModel(‘catalog/category’);
$cat->load($id);
if($id != 3):
if($cat->getIsActive()):
$catName[] =  $cat->getName();
$path[] = $cat->getUrl();
endif;
endif;
}
?>

<?php

require_once ‘app/Mage.php’;

Mage::app();

$category = Mage::getModel(‘catalog/category’);

$tree = $category->getTreeModel();

$tree->load();

$ids = $tree->getCollection()->getAllIds();   // we can get all level categories id

if ($ids):

foreach ($ids as $id){

$cat = Mage::getModel(‘catalog/category’);

$cat->load($id);

if($id != 3): // if  category id is not “root catalog” id – here root catalog id is 3

if($cat->getIsActive()): // if category is active

$catName[] =  $cat->getName(); //  To get name of the category

$path[] = $cat->getUrl(); // to get url of category

endif;

endif;

}

?>

If these post is useful to you than please give your feedback.

– Bijal Bhavsar

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: