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.create (SOAP V1)
  • catalogCategoryCreate (SOAP V2)

Create a new category and return its ID.

Aliases:

  • category.create

Arguments:

TypeNameDescription
stringsessionIdSession ID
intparentIdParent category ID
arraycategoryDataArray of catalogCategoryEntityCreate
stringstoreViewStore view ID or code (optional)

Returns:

TypeNameDescription
intattribute_idID of the created category

The categoryData content is as follows:

TypeNameDescription
stringnameName of the created category
intis_activeDefines whether the category will be visible in the frontend
intpositionPosition of the created category (optional)
ArrayOfStringavailable_sort_byAll available options by which products in the category can be sorted
stringcustom_designThe custom design for the category (optional)
intcustom_apply_to_productsApply the custom design to all products assigned to the category (optional)
stringcustom_design_fromDate starting from which the custom design will be applied to the category (optional)
stringcustom_design_toDate till which the custom design will be applied to the category (optional)
stringcustom_layout_updateCustom layout update (optional)
stringdefault_sort_byThe default option by which products in the category are sorted
stringdescriptionCategory description (optional)
stringdisplay_modeContent that will be displayed on the category view page (optional)
intis_anchorDefines whether the category will be anchored (optional)
intlanding_pageLanding page (optional)
stringmeta_descriptionCategory meta description (optional)
stringmeta_keywordsCategory meta keywords (optional)
stringmeta_titleCategory meta title (optional)
stringpage_layoutType of page layout that the category should use (optional)
stringurl_keyA relative URL path which can be entered in place of the standard target path (optional)
intinclude_in_menuDefines whether the category is visible on the top menu bar
stringfilter_price_rangePrice range of each price level displayed in the layered navigation block (optional)
intcustom_use_parent_settingsDefines whether the category will inherit custom design settings of the category to which it is assigned. 1 - Yes, 0 - No (optional)

Notes: The position parameter is deprecated, the category will be positioned anyway in the end of the list and you can not set the position directly. You should use the catalog_category.move method instead. You cannot also assign a root category to the specified store.

Examples

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

// If some stuff requires API authentication,
// then get a session token
$session = $client->login('apiUser', 'apiKey');
$result = $client->call($session, 'catalog_category.create', array(2, array(
    'name' => 'Category name',
    'is_active' => 1,
    'position' => 1,
    //<!-- position parameter is deprecated, category anyway will be positioned in the end of list
    //and you can not set position directly, use catalog_category.move instead -->
    'available_sort_by' => 'position',
    'custom_design' => null,
    'custom_apply_to_products' => null,
    'custom_design_from' => null,
    'custom_design_to' => null,
    'custom_layout_update' => null,
    'default_sort_by' => 'position',
    'description' => 'Category description',
    'display_mode' => null,
    'is_anchor' => 0,
    'landing_page' => null,
    'meta_description' => 'Category meta description',
    'meta_keywords' => 'Category meta keywords',
    'meta_title' => 'Category meta title',
    'page_layout' => 'two_columns_left',
    'url_key' => 'url-key',
    'include_in_menu' => 1,
)));

var_dump ($result);
Request Example SOAP V2
$client = new SoapClient('http://magentohost/api/v2_soap/?wsdl');

// If some stuff requires API authentication,
// then get a session token
$session = $client->login('apiUser', 'apiKey');
$result = $client->catalogCategoryCreate($session, 2, array(
    'name' => 'Category name 2',
    'is_active' => 1,
    'position' => 1,
    //<!-- position parameter is deprecated, category anyway will be positioned in the end of list
    //and you can not set position directly, use catalog_category.move instead -->
    'available_sort_by' => array('position'),
    'custom_design' => null,
    'custom_apply_to_products' => null,
    'custom_design_from' => null,
    'custom_design_to' => null,
    'custom_layout_update' => null,
    'default_sort_by' => 'position',
    'description' => 'Category description',
    'display_mode' => null,
    'is_anchor' => 0,
    'landing_page' => null,
    'meta_description' => 'Category meta description',
    'meta_keywords' => 'Category meta keywords',
    'meta_title' => 'Category meta title',
    'page_layout' => 'two_columns_left',
    'url_key' => 'url-key',
    'include_in_menu' => 1,
));

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->catalogCategoryCreate((object)array('sessionId' => $sessionId->result, 'parentId' => '5', 'categoryData' => ((object)array(
    'name' => 'category',
    'is_active' => '1',
    'position' => '1',
    'available_sort_by' => array('position'),
    'default_sort_by' => 'position',
    'description' => 'Category description',
    'is_anchor' => '1',
    'include_in_menu' => '1'
))));
var_dump($result->result);