Group Attributes

Manage Group Attributes Filter

List attributes group

GET ‎‎ https://<domain>/<api prefix>/<version>/commerce/product/list/attribute-groups/

This API endpoint will give you the list of attributes group.

Query Parameters

NameTypeDescription

offset

string

numeric - The offset indicates the starting position of the query in relation to the complete set of unpaginated items.

limit

string

The limit indicates the maximum number of items to return, default maximum number is 50, and maximum limit is 100.

group_name

string

Attribute group name.

attr_name

string

Attribute name.

Headers

NameTypeDescription

apikey*

string

apikey

Authorization*

string

Bearer access token

​HTTP/1.1 200 OK
Content-Type: application/json

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "id": <attribute_group_id>,
                "name": "<attribute_group_name>",
                "attribute_id": [
                    {
                        "id": <attribute_id>,
                        "machine_code": "<attribute_machine_code>",
                        "name": "<attribute_name>",
                        "description": "<attribute_description>",
                        "widget": "<attribute_widget_type>",
                        "attribute_for": "<attribute_for>",
                        "is_unique": <is_unique_boolean>,
                        "is_required": <is_required_boolean>,
                        "is_display": <is_display_boolean>,
                        "options": [
                            {
                                "label": "<option_label>",
                                "value": "<option_value>",
                                "status": <option_status_boolean>,
                                "weight": <option_weight>
                            },
                            ...
                        ],
                        "data_type": "<attribute_data_type>",
                        "status": <attribute_status>,
                        "created": "<created_date_time>"
                    },
                    ...
                ],
                "status": <attribute_group_status>,
                "created": "<created_date_time>"
            },
            ...
        ],
        "count": <list_count>,
        "previous": <link_for_previous_page_list>,
        "next": <link_for_next_page_list>
    }
}

Sample Code

Node

var request = require('request');
var options = {
  'method': 'GET',
  'url': '‎https://<domain>/<api prefix>/<version>/commerce/product/list/attribute-groups/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

PHP

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "‎https://<domain>/<api prefix>/<version>/commerce/product/list/attribute-groups/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "apikey: <apikey>",
    "Authorization: Bearer <access token>",
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Create attributes group

POST ‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎https://<domain>/<api prefix>/<version>/commerce/product/create/attribute-groups/

This API endpoint will create an attributes group.

Headers

NameTypeDescription

apikey*

string

apikey

Authorization*

string

Bearer access token

Request Body

NameTypeDescription

name*

string

Name of attribute

attribute_id*

array

Attribute id - require an array of attribute ids containing at least one attribute id.

​HTTP/1.1 200 OK
Content-Type: application/json

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}

Sample Code

Node

var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/commerce/product/create/attribute-groups/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  body: JSON.stringify({"name":"<name>","attribute_id":["<attribute_id>","<attribute_id>",...]})

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

PHP

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/commerce/product/create/attribute-groups/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "name":"<name>",
    "attribute_id": ["<attribute_id>","<attribute_id>"]
}',
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

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 20 characters.

400

Validation Error

attribute_id

Attribute id is required.

attribute_id is not valid or This field may not be blank.

attribute_id is not exist.

Update attributes group

POST ‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎https://<domain>/<api prefix>/<version>/commerce/product/update/attribute-groups/

This API endpoint will update an attributes groups.

Headers

NameTypeDescription

apikey*

string

apikey

Authorization*

string

Bearer access token

Request Body

NameTypeDescription

attrgroup_id*

string

Id of an attributes group that wants to update.

name*

string

Give a new name if u want to update the name of the group else give the existing name.

remove_attr

array

An array of attribute ids that wants to remove from the attributes group.

add_attr

array

An array of attribute ids that wants to add to the attributes group.

​HTTP/1.1 200 OK
Content-Type: application/json

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}

Sample Code

Node

var request = require('request');
var options = {
  'method': 'POST',
  'url': '‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎https://<domain>/<api prefix>/<version>/commerce/product/update/attribute-groups/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  body: JSON.stringify({"attrgroup_id":"<attrgroup_id>","name":"<name>","add_attr":["<attr_id>","<attr_id>",...],"remove_attr":["<attr_id>","<attr_id>",...]})

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

PHP

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => '‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎https://<domain>/<api prefix>/<version>/commerce/product/update/attribute-groups/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "attrgroup_id":"<attrgroup_id>",
    "name":"<name>",
    "add_attr": ["<attr_id>","<attr_id>",...],
    "remove_attr": ["<attr_id>","<attr_id>",...]
}',
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Error Responses

Status Code

Error Type

Field

Description

400

Invalid Input

attrgroup_id

This field is required.

attrgroup_id is not valid or This field may not be blank

400

Validation Error

name

This field is required.

This field may not be blank.

Ensure this field has no more than 20 characters.

400

Validation Error

attribute_id

<attribute_id> is not valid or This field may not be blank.

<attribute_id> is not exist.

<attribute_id> is already exist in group.

Last updated