Catalog Category API¶
Introduction¶
The Catalog Category API allows you to manage product categories in your OpenMage store. You can retrieve category information, create new categories, update existing ones, move categories within the category tree, and manage product assignments to categories.
Available Methods¶
currentStore
¶
Sets the current store for category operations.
Method Name: catalog_category.currentStore
Parameters:
store
(string|int, required) - Store ID or code
Return:
- (int) - Current store ID
Example Request:
{
"jsonrpc": "2.0",
"method": "call",
"params": [
"session_id",
"catalog_category.currentStore",
"default"
],
"id": 1
}
Example Response:
tree¶
Retrieve category tree.
Method Name: catalog_category.tree
Parameters:
parentId
(int, optional) - Parent category ID (default: 1 - root category)store
(string|int, optional) - Store ID or code
Return:
- (array) - Category tree with the following structure:
category_id
(int) - Category IDparent_id
(int) - Parent category IDname
(string) - Category nameis_active
(boolean) - Whether the category is activeposition
(int) - Positionlevel
(int) - Level in the category treechildren
(array) - Array of child categories with the same structure
Example Request:
{
"jsonrpc": "2.0",
"method": "call",
"params": [
"session_id",
"catalog_category.tree",
[1, "default"]
],
"id": 1
}
Example Response:
{
"jsonrpc": "2.0",
"result": {
"category_id": 1,
"parent_id": 0,
"name": "Root",
"is_active": true,
"position": 0,
"level": 0,
"children": [
{
"category_id": 2,
"parent_id": 1,
"name": "Default Category",
"is_active": true,
"position": 1,
"level": 1,
"children": []
}
]
},
"id": 1
}
level¶
Retrieve level of categories for category/store view/website.
Method Name: catalog_category.level
Parameters:
website
(string|int, optional) - Website ID or codestore
(string|int, optional) - Store ID or codecategoryId
(int, optional) - Category ID
Return:
- (array) - Array of categories with the following structure:
category_id
(int) - Category IDparent_id
(int) - Parent category IDname
(string) - Category nameis_active
(boolean) - Whether the category is activeposition
(int) - Positionlevel
(int) - Level in the category tree
Example Request:
{
"jsonrpc": "2.0",
"method": "call",
"params": [
"session_id",
"catalog_category.level",
[null, "default", 2]
],
"id": 1
}
Example Response:
{
"jsonrpc": "2.0",
"result": [
{
"category_id": 3,
"parent_id": 2,
"name": "Furniture",
"is_active": true,
"position": 1,
"level": 2
},
{
"category_id": 4,
"parent_id": 2,
"name": "Electronics",
"is_active": true,
"position": 2,
"level": 2
}
],
"id": 1
}
info¶
Retrieve category data.
Method Name: catalog_category.info
Parameters:
categoryId
(int, required) - Category IDstore
(string|int, optional) - Store ID or codeattributes
(array, optional) - Array of attributes to return
Return:
- (array) - Category data with the following structure:
category_id
(int) - Category IDis_active
(boolean) - Whether the category is activeposition
(int) - Positionlevel
(int) - Level in the category tree- Additional attributes as requested
parent_id
(int) - Parent category IDchildren
(string) - Comma-separated list of child category IDsall_children
(string) - Comma-separated list of all child category IDs
Example Request:
{
"jsonrpc": "2.0",
"method": "call",
"params": [
"session_id",
"catalog_category.info",
[3, "default", ["name", "description", "url_key"]]
],
"id": 1
}
Example Response:
{
"jsonrpc": "2.0",
"result": {
"category_id": 3,
"is_active": true,
"position": 1,
"level": 2,
"name": "Furniture",
"description": "Furniture category description",
"url_key": "furniture",
"parent_id": 2,
"children": "5,6,7",
"all_children": "5,6,7,8,9"
},
"id": 1
}
create¶
Create new category.
Method Name: catalog_category.create
Parameters:
parentId
(int, required) - Parent category IDcategoryData
(array, required) - Category data:name
(string, required) - Category nameis_active
(boolean, optional) - Whether the category is activeposition
(int, optional) - Positionavailable_sort_by
(array, optional) - Available sort by optionsdefault_sort_by
(string, optional) - Default sort by optioninclude_in_menu
(boolean, optional) - Include in navigation menuurl_key
(string, optional) - URL keydescription
(string, optional) - Descriptionmeta_title
(string, optional) - Meta titlemeta_keywords
(string, optional) - Meta keywordsmeta_description
(string, optional) - Meta descriptiondisplay_mode
(string, optional) - Display mode- Other custom attributes
store
(string|int, optional) - Store ID or code
Return:
- (int) - ID of the created category
Example Request:
{
"jsonrpc": "2.0",
"method": "call",
"params": [
"session_id",
"catalog_category.create",
[
2,
{
"name": "New Category",
"is_active": true,
"position": 3,
"description": "New category description",
"url_key": "new-category"
},
"default"
]
],
"id": 1
}
Example Response:
Possible Errors:
data_invalid
- Invalid data providednot_exists
- Parent category does not exist
update¶
Update category data.
Method Name: catalog_category.update
Parameters:
categoryId
(int, required) - Category IDcategoryData
(array, required) - Category data to update (same structure as in create method)store
(string|int, optional) - Store ID or code
Return:
- (boolean) - True on success
Example Request:
{
"jsonrpc": "2.0",
"method": "call",
"params": [
"session_id",
"catalog_category.update",
[
3,
{
"name": "Updated Category Name",
"description": "Updated description"
},
"default"
]
],
"id": 1
}
Example Response:
Possible Errors:
data_invalid
- Invalid data providednot_exists
- Category does not exist
move¶
Move category in tree.
Method Name: catalog_category.move
Parameters:
categoryId
(int, required) - Category ID to moveparentId
(int, required) - New parent category IDafterId
(int, optional) - Category ID to place the moved category after (if null, the category will be placed at the end)
Return:
- (boolean) - True on success
Example Request:
{
"jsonrpc": "2.0",
"method": "call",
"params": [
"session_id",
"catalog_category.move",
[3, 4, null]
],
"id": 1
}
Example Response:
Possible Errors:
not_moved
- Category could not be movednot_exists
- Category does not exist
delete¶
Delete category.
Method Name: catalog_category.delete
Parameters:
categoryId
(int, required) - Category ID to delete
Return:
- (boolean) - True on success
Example Request:
{
"jsonrpc": "2.0",
"method": "call",
"params": [
"session_id",
"catalog_category.delete",
3
],
"id": 1
}
Example Response:
Possible Errors:
not_deleted
- Category could not be deletednot_exists
- Category does not exist
assignedProducts
¶
Retrieve list of assigned products to category.
Method Name: catalog_category.assignedProducts
Parameters:
categoryId
(int, required) - Category IDstore
(string|int, optional) - Store ID or code
Return:
- (array) - Array of products with the following structure:
product_id
(int) - Product IDtype
(string) - Product typeset
(int) - Attribute set IDsku
(string) - Product SKUposition
(int) - Position in category
Example Request:
{
"jsonrpc": "2.0",
"method": "call",
"params": [
"session_id",
"catalog_category.assignedProducts",
[3, "default"]
],
"id": 1
}
Example Response:
{
"jsonrpc": "2.0",
"result": [
{
"product_id": 14,
"type": "simple",
"set": 4,
"sku": "product1",
"position": 1
},
{
"product_id": 15,
"type": "simple",
"set": 4,
"sku": "product2",
"position": 2
}
],
"id": 1
}
assignProduct
¶
Assign product to category.
Method Name: catalog_category.assignProduct
Parameters:
categoryId
(int, required) - Category IDproductId
(int|string, required) - Product ID or SKUposition
(int, optional) - Position in categoryidentifierType
(string, optional) - Type of product identifier (‘sku’ or null for ID)
Return:
- (boolean) - True on success
Example Request:
{
"jsonrpc": "2.0",
"method": "call",
"params": [
"session_id",
"catalog_category.assignProduct",
[3, "product3", 3, "sku"]
],
"id": 1
}
Example Response:
Possible Errors:
data_invalid
- Invalid data providednot_exists
- Category does not existproduct_not_exists
- Product does not exist
updateProduct
¶
Update product assignment.
Method Name: catalog_category.updateProduct
Parameters:
categoryId
(int, required) - Category IDproductId
(int|string, required) - Product ID or SKUposition
(int, optional) - New position in categoryidentifierType
(string, optional) - Type of product identifier (‘sku’ or null for ID)
Return:
- (boolean) - True on success
Example Request:
{
"jsonrpc": "2.0",
"method": "call",
"params": [
"session_id",
"catalog_category.updateProduct",
[3, "product1", 5, "sku"]
],
"id": 1
}
Example Response:
Possible Errors:
data_invalid
- Invalid data providednot_exists
- Category does not existproduct_not_exists
- Product does not existproduct_not_assigned
- Product is not assigned to the category
removeProduct
¶
Remove product assignment from category.
Method Name: catalog_category.removeProduct
Parameters:
categoryId
(int, required) - Category IDproductId
(int|string, required) - Product ID or SKUidentifierType
(string, optional) - Type of product identifier (‘sku’ or null for ID)
Return:
- (boolean) - True on success
Example Request:
{
"jsonrpc": "2.0",
"method": "call",
"params": [
"session_id",
"catalog_category.removeProduct",
[3, "product1", "sku"]
],
"id": 1
}
Example Response:
Possible Errors:
not_exists
- Category does not existproduct_not_exists
- Product does not exist