Open2b versione 7.5

attributes

attributes.find

Returns the attributes that meet the given conditions.

Request

Admin SDK
Admin.api('commerce.attributes.find', request, function(response) { … });
HTTP POST
/api/v10/commerce.attributes.find
{
  "conditions" : { // returns only the attributes …
    "ids" : [ 81, … ],  // … with these identifiers - int(1…)
    "after" : 55 // … with identifier after this value - int(0…)
  },
  "language" : "en", // language ( ISO code ) of the texts to return - string(2)
  "fields" : [ "id", "code", … ], // fields to return - string
  "order" : [ "name" ], // sort order of returned attributes, can contain "id", "-id", "code", "-code", "name" and "-name" - string
  "limit" : 10, // maximum number of attributes to return - int(1…)
  "first" : 0 // index of the first attribute to return - int(0…)
}

Response

{
  "status" : "ok",
  "attributes" : [ {
    "id" : 81, // identifier - int(1…)
    "code" : "SHIRT COLOR", // code - string(1…32)
    "position" : 3, // position - int(1…)
    "name" : { // name - string(2) -> string(0…60)
      "en" : "Color",
      "it" : "Colore",
      …
    },
    "showName" : true // indicates if the name should be displayed
  }, … ]
}

attributes.get

Returns an attribute given its identifier.

Admin SDK
Admin.api('commerce.attributes.get', request, function(response) { … });
HTTP POST
/api/v10/commerce.attributes.get

Request

{
  "id" : 81, // identifier of the attribute (required) - int(1…)
  "language" : "en", // language ( ISO code ) of the texts to return - string(2)
  "fields" : [ "id", "code", … ]  // fields to return - string
}

Response

{
  "status" : "ok",
  "attribute" : { // (can be null)
    "id" : 81, // identifier - int(1…)
    "code" : "SHIRT COLOR", // code - string(1…32)
    "position" : 3, // position - int(1…)
    "name" : { // name - string(2) -> string(0…60)
      "en" : "Color",
      "it" : "Colore",
      …
    },
    "showName" : true // indicates if the name should be displayed
  }
}

attributes.count

Number of attributes that meet the given conditions.

Request

Admin SDK
Admin.api('commerce.attributes.count', request, function(response) { … });
HTTP POST
/api/v10/commerce.attributes.count
{
  "conditions" : { // counts only the attributes …
    "ids" : [ 81, … ],  // … with these identifiers - int(1…)
    "after" : 55 // … with identifier after this value - int(0…)
  }
}

Response

{
  "status" : "ok",
  "count" : 89 // number of attributes - int(0…)
}

attributes.create

Creates a new attribute.

Request

Admin SDK
Admin.api('commerce.attributes.create', request, function(response) { … });
HTTP POST
/api/v10/commerce.attributes.create
{
  "attribute" : {
    "code" : "SHIRT COLOR", // code (required) - string(1…32)
    "position" : 3, // position - int(1…)
    "name" : { // name - string(2) -> string(0…60)
      "en" : "Color",
      "it" : "Colore",
      …
    },
    "showName" : true // indicates if the name should be displayed
  }
}

Response

{
  "status" : "ok",
  "id" : 81 // identifier of the new attribute - int(1…)
}

attributes.update

Updates an attribute. Any fields left out of the request will remain unchanged.

Request

Admin SDK
Admin.api('commerce.attributes.update', request, function(response) { … });
HTTP POST
/api/v10/commerce.attributes.update
{
  "id" : 81, // identifier of the attribute to update (required) - int(1…)
  "attribute" : { // attribute's fields to update (required)
    "code" : "SHIRT COLOR", // code - string(1…32)
    "position" : 3, // position - int(1…)
    "name" : { // name - string(2) -> string(0…60)
      "en" : "Color",
      "it" : "Colore",
      …
    },
    "showName" : true // indicates if the name should be displayed
  }
}

Response

{
  "status" : "ok"
}

Errors

field Type Description
id NotFound Attribute <id> does not exist

attributes.delete

Deletes one or more attributes.

Request

Admin SDK
Admin.api('commerce.attributes.delete', request, function(response) { … });
HTTP POST
/api/v10/commerce.attributes.delete
{
  "ids" : [ 81, 12, 33, … ] // identifiers of the attributes to delete (required) - int(1…)
}

Response

{
  "status" : "ok"
}