get category list by magento api


Category Structure in Magento API

<?php
$website = 'yourshop.com';
$api_login = 'blabla';
$api_key = 'blabla';
$proxy = new SoapClient('http://'.$website.'/index.php/api/soap/?wsdl');
$sessionId = $proxy->login($api_login, $api_key);

$allCategories = $proxy->call($sessionId, 'category.tree'); // Get all categories.
 echo '<pre>';
echo print_r($allCategories);
echo '</pre>';
?>

You will get OutPut like this

Array
(
[category_id] => 1
[parent_id] => 0
[name] => Root
[is_active] =>
[position] => 0
[level] => 0
[children] => Array
(
[0] => Array
(
[category_id] => 2
[parent_id] => 1
[name] =>
[is_active] =>
[position] => 1
[level] => 1
[children] => Array
(
[0] => Array
(
[category_id] => 3
[parent_id] => 2
[name] => Sub Cat 1
[is_active] => 1
[position] => 1
[level] => 2
[children] => Array
(
)

)

[1] => Array
(
[category_id] => 4
[parent_id] => 2
[name] => Sub Cat 2
[is_active] => 1
[position] => 2
[level] => 2
[children] => Array
(
)

)

)

)

)

)

Share on Facebook




About Pragnesh Karia

Pragnesh Karia, Open Source Enthusiast, Software Professional, Software Developer, Technical Lead ,Magento, Joomla ,Joomla LMS , Moodel LMS ,PHP ,Mysql, Ajax, Javascript, Jquery, Linux, Fan of Open Sources , Annet Technologies , SEO Analyst , Mootools