Create folder with in magento like webservice
I have create file webservice/getcategories.php
getStoreCategories()
<?php
require_once '../app/Mage.php';
Mage::app();
header("Content-Type: application/json");
?>
<?php
$_helper = Mage::helper('catalog/category');
$_categories = $_helper->getStoreCategories();
$data=array();
if (count($_categories) > 0){
?>
<ul id="nav">
<?php
$i=0;
foreach($_categories as $_category)
{
$_category = Mage::getModel('catalog/category')->load($_category->getId());
$_subcategories = $_category->getChildrenCategories();
if (count($_subcategories) > 0)
{
?>
<li>
<?php
echo $_category->getName();
echo $_category->getId();
?>
<ul>
<?php
$j=0;
foreach($_subcategories as $_subcategory){
?>
<li>
<?php
echo $_subcategory->getName();
echo $_subcategory->getId();
$_subsubcategories = $_subcategory->getChildrenCategories();
?>
<ul>
<?php
$k=0;
foreach($_subsubcategories as $_subsubcat)
{?>
<li><?php
echo $_subsubcat->getName();
echo $_subsubcat->getId();
$subsubcategory[$k]=array("subsubcatname" =>$_subsubcat->getName(),"subsubcatid"=>$_subsubcat->getId());
?></li>
<?php
$k++;
} ?>
</ul>
</li>
<?php
$subcategory[$j]=array("subcatname" =>$_subcategory->getName(),"subcatid"=>$_subcategory->getId(),"subsubcategorylist"=>$subsubcategory);
$j++;
}
?>
</ul>
</li>
<?php
}
$data[$i]=array("catid"=>$_category->getId(),"catname" =>$_category->getName(),"subcategory"=>$subcategory);
$i++;
}
?>
</ul>
<?php
}
$data2 = json_encode($data);
echo $data2;
?>
1 comments:
This is a great post. I like this topic.This site has lots of advantage. It helps me in many ways.Thanks for posting this again.
magento development company in bangalore
EmoticonEmoticon