Product Category
Manage product category

List Product Categories

get
β€Ž
https://<domain>/<api prefix>/<version>/commerce/product/list/categories/

Sample Code

Node
1
var request = require('request');
2
var options = {
3
'method': 'GET',
4
'url': 'https://<domain>/<api prefix>/<version>/commerce/product/list/categories/',
5
'headers': {
6
'apikey': '<apikey>',
7
'Authorization': 'Bearer <access token>',
8
}
9
};
10
request(options, function (error, response) {
11
if (error) throw new Error(error);
12
console.log(response.body);
13
});
14
​
Copied!
PHP
1
<?php
2
​
3
$curl = curl_init();
4
​
5
curl_setopt_array($curl, array(
6
CURLOPT_URL => "https://<domain>/<api prefix>/<version>/commerce/product/list/categories/",
7
CURLOPT_RETURNTRANSFER => true,
8
CURLOPT_ENCODING => "",
9
CURLOPT_MAXREDIRS => 10,
10
CURLOPT_TIMEOUT => 0,
11
CURLOPT_FOLLOWLOCATION => true,
12
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
13
CURLOPT_CUSTOMREQUEST => "GET",
14
CURLOPT_HTTPHEADER => array(
15
"apikey: <apikey>",
16
"Authorization: Bearer <access token>",
17
),
18
));
19
​
20
$response = curl_exec($curl);
21
​
22
curl_close($curl);
23
echo $response;
Copied!

Create Product Category

Create a Product category (Product - Type).
  • First, Get the list of enabled product type method configuration through the below-provided endpoint.
  • Then Create product type through the post method.

Active Product Type Method Configurations

get
β€Ž
https://<domain>/<api prefix>/<version>/commerce/product/get/producttype/methodconf/

Sample Code

Node
1
var request = require('request');
2
var options = {
3
'method': 'GET',
4
'url': 'https://<domain>/<api prefix>/<version>/commerce/product/get/producttype/methodconf/',
5
'headers': {
6
'apikey': '<apikey>',
7
'Authorization': 'Bearer <access token>',
8
}
9
};
10
request(options, function (error, response) {
11
if (error) throw new Error(error);
12
console.log(response.body);
13
});
14
​
Copied!
PHP
1
<?php
2
​
3
$curl = curl_init();
4
​
5
curl_setopt_array($curl, array(
6
CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/commerce/product/get/producttype/methodconf/',
7
CURLOPT_RETURNTRANSFER => true,
8
CURLOPT_ENCODING => '',
9
CURLOPT_MAXREDIRS => 10,
10
CURLOPT_TIMEOUT => 0,
11
CURLOPT_FOLLOWLOCATION => true,
12
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
13
CURLOPT_CUSTOMREQUEST => 'GET',
14
CURLOPT_HTTPHEADER => array(
15
'apikey: <apikey>',
16
'Authorization: Bearer <access token>',
17
),
18
));
19
​
20
$response = curl_exec($curl);
21
​
22
curl_close($curl);
23
echo $response;
24
​
Copied!

Create Product Type

post
β€Ž
https://<domain>/<api prefix>/<version>/commerce/product/create/category/
Body Parameters are JSON.stringify, Refer below block for the body parameter structure, and also refer sample code.
1
{
2
"name": "<product-type-name>",
3
"translations": {
4
"<language_code>": "<name>",
5
"<language_code>": "<name>",
6
...
7
},
8
"method": [
9
"<method_name>",
10
"<method_name>",
11
...
12
],
13
"catalogue_ids": [
14
<catalogue_id>,
15
<catalogue_id>,
16
...
17
],
18
"attr_grp_ids": [
19
<attr_grp_ids>,
20
<attr_grp_ids>,
21
...
22
]
23
}
Copied!

Sample Code

Node
1
var request = require('request');
2
var options = {
3
'method': 'POST',
4
'url': 'https://<domain>/<api prefix>/<version>/commerce/product/create/category/',
5
'headers': {
6
'apikey': '<apikey>',
7
'Authorization': 'Bearer <access token>',
8
'Content-Type': 'application/json',
9
},
10
body: JSON.stringify({"name":"<method-name>","translations":{"<language_code>":"<name>","<language_code>":"<name>"},"method":["<method_name>","<method_name>"],"catalogue_ids":[<id>,<id>],"attr_grp_ids":[<id>,<id>]})
11
};
12
request(options, function (error, response) {
13
if (error) throw new Error(error);
14
console.log(response.body);
15
});
16
​
Copied!
PHP
1
<?php
2
​
3
$curl = curl_init();
4
​
5
curl_setopt_array($curl, array(
6
CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/commerce/product/create/category/',
7
CURLOPT_RETURNTRANSFER => true,
8
CURLOPT_ENCODING => '',
9
CURLOPT_MAXREDIRS => 10,
10
CURLOPT_TIMEOUT => 0,
11
CURLOPT_FOLLOWLOCATION => true,
12
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
13
CURLOPT_CUSTOMREQUEST => 'POST',
14
CURLOPT_POSTFIELDS =>'{
15
"name": "<method_name>",
16
"translations": {
17
"<language_code>": "<name>",
18
"<language_code>": "<name>"
19
},
20
"method": [
21
"<method_name>",
22
"<method_name>"
23
],
24
"catalogue_ids": [
25
<id>,
26
<id>
27
],
28
"attr_grp_ids": [
29
<id>,
30
<id>
31
]
32
}',
33
CURLOPT_HTTPHEADER => array(
34
'apikey: <apikey>',
35
'Authorization: Bearer <access token>',
36
'Content-Type: application/json',
37
),
38
));
39
​
40
$response = curl_exec($curl);
41
​
42
curl_close($curl);
43
echo $response;
44
​
Copied!

Error Responses

Status Code
Error Type
FIeld
Description
400
Validation Error
name
This field is required.
This field may not be blank.
Ensure this field has no more than 250 characters.
400
Validation Error
catalogue_ids
Provided <catalogue_ids> is not a valid catalogue id
Provided <catalogue_ids> does not exist
400
Validation Error
attr_grp_ids
Provide at least one group
Provided <attr_grp_id> is not a valid group id
Provided <attr_grp_id> does not exist

Update Product Category

post
β€Ž
https://<domain>/<api prefix>/<version>/commerce/product/update/category/
Body Parameters are JSON.stringify, Refer below block for the body parameter structure, and also refer sample code.
1
{
2
"ptype":<product_typ>,
3
"name": "<product-type-name>",
4
"translations": {
5
"<language_code>": "<name>",
6
"<language_code>": "<name>",
7
...
8
},
9
"method": [
10
"<method_name>",
11
"<method_name>",
12
...
13
],
14
"catalogue_ids": [
15
<catalogue_id>,
16
<catalogue_id>,
17
...
18
],
19
"attr_grp_ids": [
20
<attr_grp_ids>,
21
<attr_grp_ids>,
22
...
23
]
24
}
Copied!

Sample Code

Node
1
var request = require('request');
2
var options = {
3
'method': 'POST',
4
'url': 'https://<domain>/<api prefix>/<version>/commerce/product/update/category/',
5
'headers': {
6
'apikey': '<apikey>',
7
'Authorization': 'Bearer <access token>',
8
'Content-Type': 'application/json',
9
},
10
body: JSON.stringify({"ptype":<product_type_id>,"name":"<name>","attr_grp_ids":[<id>,<id>],"translations":{"<language_code>":"<name>","<language_code>":"<name>"},"method":["<method_name>","<method_name>"],"catalogue_ids":[<id>,<id>]})
11
​
12
};
13
request(options, function (error, response) {
14
if (error) throw new Error(error);
15
console.log(response.body);
16
});
17
​
Copied!
PHP
1
<?php
2
​
3
$curl = curl_init();
4
​
5
curl_setopt_array($curl, array(
6
CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/commerce/product/update/category/',
7
CURLOPT_RETURNTRANSFER => true,
8
CURLOPT_ENCODING => '',
9
CURLOPT_MAXREDIRS => 10,
10
CURLOPT_TIMEOUT => 0,
11
CURLOPT_FOLLOWLOCATION => true,
12
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
13
CURLOPT_CUSTOMREQUEST => 'POST',
14
CURLOPT_POSTFIELDS =>'{
15
"ptype":<product_type_id>,
16
"name":"<name>",
17
"attr_grp_ids":[
18
<id>,
19
<id>
20
],
21
"translations": {
22
"<language_code>":"<name>",
23
"<language_code>":"<name>"
24
},
25
"method": [
26
<method_name>",
27
<method_name>"
28
],
29
"catalogue_ids": [
30
<id>,
31
<id>
32
]
33
}',
34
CURLOPT_HTTPHEADER => array(
35
'apikey: <apikey>',
36
'Authorization: Bearer <access token>',
37
'Content-Type: application/json',
38
),
39
));
40
​
41
$response = curl_exec($curl);
42
​
43
curl_close($curl);
44
echo $response;
Copied!

Error Responses

Status Code
Error Type
FIeld
Description
400
Validation Error
ptype
Product Type id is required.
This field may not be blank.
Product Type does not exist.
400
Validation Error
name
This field is required.
This field may not be blank.
Ensure this field has no more than 250 characters.
400
Validation Error
catalogue_ids
Provided <catalogue_ids> is not a valid catalogue id
Provided <catalogue_ids> does not exist
400
Validation Error
attr_grp_ids
Provide at least one group
Provided <attr_grp_id> is not a valid group id
Provided <attr_grp_id> does not exis

Delete Product Category

delete
β€Ž
https://<domain>/<api prefix>/<version>/commerce/product/delete/category/?id=<category_id>

Sample Code

Node
1
var request = require('request');
2
var options = {
3
'method': 'DELETE',
4
'url': 'https://<domain>/<api prefix>/<version>/commerce/product/delete/category/?id=<category_id>',
5
'headers': {
6
'apikey': '<apikey>',
7
'Authorization': 'Bearer <access token>',
8
},
9
formData: {}
10
};
11
request(options, function (error, response) {
12
if (error) throw new Error(error);
13
console.log(response.body);
14
});
15
​
Copied!
PHP
1
<?php
2
​
3
$curl = curl_init();
4
​
5
curl_setopt_array($curl, array(
6
CURLOPT_URL => "https://<domain>/<api prefix>/<version>/commerce/product/delete/category/?id=<category_id>",
7
CURLOPT_RETURNTRANSFER => true,
8
CURLOPT_ENCODING => "",
9
CURLOPT_MAXREDIRS => 10,
10
CURLOPT_TIMEOUT => 0,
11
CURLOPT_FOLLOWLOCATION => true,
12
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
13
CURLOPT_CUSTOMREQUEST => "DELETE",
14
CURLOPT_HTTPHEADER => array(
15
"apikey: <apikey>",
16
"Authorization: Bearer <access token>",
17
),
18
));
19
​
20
$response = curl_exec($curl);
21
​
22
curl_close($curl);
23
echo $response;
24
​
Copied!

Error Responses

Status Code
Error Type
FIeld
Description
400
Invalid Input
id
Category id is not valid.
Category does not exist. This field may not be blank Category id is required.
401
Request Failed
​
There are products in this category.you can't delete it
Category can't delete or remove
Last modified 1mo ago