Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Module: Mage_Catalog

The Mage_Catalog module allows you to manage categories and products.

Resource Name: catalog_category

Aliases:

  • category
Method:
  • catalog_category.tree (SOAP V1)
  • catalogCategoryTree (SOAP V2)

Allows you to retrieve the hierarchical tree of categories.

Aliases:

  • category.tree

Arguments:

TypeNameDescription
stringsessionIdSession ID
stringparentIdID of the parent category (optional)
stringstoreViewStore view (optional)

Returns:

TypeNameDescription
arraytreeArray of catalogCategoryTree

The catalogCategoryTree content is as follows:

TypeNameDescription
intcategory_idCategory ID
intparent_idParent category ID
stringnameCategory name
intpositionCategory position
intlevelCategory level
arraychildrenArray of CatalogCategoryEntities

The catalogCategoryEntity content is as follows:

TypeNameDescription
intcategory_idCategory ID
intparent_idParent category ID
stringnameCategory name
intis_activedefines whether the category is active
intpositionCategory position
intlevelCategory level
arraychildrenArray of CatalogCategoryEntities

Examples

Request Example SOAP V1
$client = new SoapClient('http://magentohost/api/soap/?wsdl');

// If somestuff requires API authentication,
// then get a session token
$session = $client->login('apiUser', 'apiKey');

$result = $client->call($session, 'catalog_category.tree');
var_dump($result);

// If you don't need the session anymore
//$client->endSession($session);
Request Example SOAP V2
$proxy = new SoapClient('http://magentohost/api/v2_soap/?wsdl'); // TODO : change url
$sessionId = $proxy->login('apiUser', 'apiKey'); // TODO : change login and pwd if necessary

$result = $proxy->catalogCategoryTree($sessionId);
var_dump($result);
Request Example SOAP V2 (WS-I Compliance Mode)
$proxy = new SoapClient('http://magentohost/api/v2_soap/?wsdl');

$sessionId = $proxy->login((object)array('username' => 'apiUser', 'apiKey' => 'apiKey'));

$result = $proxy->catalogCategoryTree((object)array('sessionId' => $sessionId->result, 'parentId' => '15'));
var_dump($result->result);
Response Example SOAP V1
array
  'category_id' => string '1' (length=1)
  'parent_id' => string '0' (length=1)
  'name' => string 'Root Catalog' (length=12)
  'is_active' => null
  'position' => string '0' (length=1)
  'level' => string '0' (length=1)
  'children' =>
    array
      0 =>
        array
          'category_id' => string '2' (length=1)
          'parent_id' => string '1' (length=1)
          'name' => string 'Default Category' (length=16)
          'is_active' => string '1' (length=1)
          'position' => string '1' (length=1)
          'level' => string '1' (length=1)
          'children' =>
            array
              ...
      1 =>
        array
          'category_id' => string '3' (length=1)
          'parent_id' => string '1' (length=1)
          'name' => string 'root_category' (length=13)
          'is_active' => string '1' (length=1)
          'position' => string '2' (length=1)
          'level' => string '1' (length=1)
          'children' =>
            array
              ...