Open2b versione 7.5

attribute-values

attribute-values.find

Returns the attribute values that meet the given conditions.

Request

Admin SDK
Admin.api('commerce.attribute-values.find', request, function(response) { … });
HTTP POST
/api/v10/commerce.attribute-values.find
{
  "conditions" : { // returns the attribute values …
    "ids" : [ 46, 19, … ], // … with these identifiers - int(1…)
    "attributes" : [ 81, 22, … ], // … that belong to these attributes (id) - int(1…)
    "after" : 9 // … 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 attribute values, can contain "id", "-id", "attribute", "-attribute", "code", "-code",
                        // "name", "-name", "position" and "-position" - string
  "limit" : 10, // maximum number of attribute values to return - int(1…)
  "first" : 0 // index of the first attribute value to return - int(0…)
}

Response

{
  "status" : "ok",
  "values" : [ {
    "id" : 46, // identifier - int(1…)
    "attribute" : 81, // attribute (id) - int(1…)
    "code" : "RED", // code - string(1…32)
    "name" : { // name - string(2) -> string(0…60)
      "en" : "Red",
      "it" : "Rosso",
      …
    },
    "description" : { // description - string(2) -> string(0…1000)
      "en" : "...",
      "it" : "...",
      …
    },
    "canonicalURL" : { // canonical URL - string(2) -> string(10…)
      "en" : "https://www.site.com/Red",
      "it" : "https://www.site.com/it/Rosso",
      …
    },
    "position" : 3, // position - int(1…)
    "icon" : { // icon (can be null)
      "color" : null, // color, hexadecimal format (can be null) - string(6)
      "image" : { // image (can be null)
        "url" : "https://…", // image URL - string(10…)
        "width"  : 16, // width in pixel - int(1…100)
        "height" : 16 // height in pixel - int(1…100)
      }
    }
  }, … ]
}

attribute-values.get

Returns an attribute value given its identifier.

Request

Admin SDK
Admin.api('commerce.attribute-values.get', request, function(response) { … });
HTTP POST
/api/v10/commerce.attribute-values.get
{
  "id" : 46, // identifier of the attribute value (required) - int(1…)
  "language" : "en", // language ( ISO code ) of the texts to return - string(2)
  "fields" : [ "id", "code", "name", … ] // fields to return - string
}

Response

{
  "status" : "ok",
  "value" : { // (can be null)
    "id" : 46, // identifier - int(1…)
    "attribute" : 81, // attribute (id) - int(1…)
    "code" : "RED", // code - string(1…32)
    "name" : { // name - string(2) -> string(0…60)
      "en" : "Red",
      "it" : "Rosso",
      …
    },
    "description" : { // description - string(2) -> string(0…1000)
      "en" : "...",
      "it" : "...",
      …
    },
    "canonicalURL" : { // canonical URL - string(2) -> string(10…)
      "en" : "https://www.site.com/Red",
      "it" : "https://www.site.com/it/Rosso",
      …
    },
    "position" : 3, // position - int(1…)
    "icon" : { // icon (can be null)
      "color" : null, // color, hexadecimal format (can be null) - string(6)
      "image" : { // image (can be null)
        "url" : "https://…", // image URL - string(10…)
        "width"  : 16, // width in pixel - int(1…100)
        "height" : 16 // height in pixel - int(1…100)
      }
    },
    "products" : [ 281, 89, … ] // products (id) that have this attribute value - int(1…)
  }
}

attribute-values.count

Number of attribute values that meet the given conditions.

Request

Admin SDK
Admin.api('commerce.attribute-values.count', request, function(response) { … });
HTTP POST
/api/v10/commerce.attribute-values.count
{
  "conditions" : { // returns the attribute values …
    "ids" : [ 46, 19, … ], // … with these identifiers - int(1…)
    "attributes" : [ 81, 22, … ], // … that belong to these attributes (id) - int(1…)
    "after" : 9 // … with identifier after this value - int(0…)
  }
}

Response

{
  "status" : "ok",
  "count" : 12 // number of attribute values - int(0…)
}

attribute-values.create

Creates a new attribute value.

Request

Admin SDK
Admin.api('commerce.attribute-values.create', request, function(response) { … });
HTTP POST
/api/v10/commerce.attribute-values.create
{
  "value" : { // attribute value to create (required)
    "attribute" : 81, // attribute (id) (required) - int(1…)
    "code" : "RED", // code (required) - string(1…32)
    "name" : { // name - string(2) -> string(0…60)
      "en" : "Red",
      "it" : "Rosso",
      …
    },
    "description" : { // description - string(2) -> string(0…1000)
      "en" : "...",
      "it" : "...",
      …
    },
    "position" : 3, // position - int(1…)
    "icon" : { // icon (can be null)
      "color" : null, // color, hexadecimal format (can be null) - string(6)
      "image" : { // image (can be null)
        "name" : "icon.png", // file name - string(1…255)
        "content" : "N3R…zaA==" // content encoded in base64 - string(100…50000)
      }
    }
  }
}

Response

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

Errors

Field Type Description
attribute NotFound Attribute <attribute> does not exist
code AlreadyExists Attribute value code '<code>' already exists for attribute <attribute>
icon Malformed '<color>' is not a valid hexadecimal color
icon Malformed 'color' or 'image' are required
icon Malformed Both 'color' and 'image' can not be in an icon
image Malformed Image format '<format>' is not supported
image Malformed Image is corrupted or is not an image
image Malformed Image size can not be greater than 100 KB
image Malformed Image width and height must be less than 100 pixels

attribute-values.update

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

Request

Admin SDK
Admin.api('commerce.attribute-values.update', request, function(response) { … });
HTTP POST
/api/v10/commerce.attribute-values.update
{
  "id" : 43, // identifier of the attribute value to update (required)
  "value" : { // attribute value's fields to update (required)
    "code" : "RED", // code - string(1…32)
    "name" : { // name - string(2) -> string(0…60)
      "en" : "Red",
      "it" : "Rosso",
      …
    },
    "description" : { // description - string(2) -> string(0…1000)
      "en" : "...",
      "it" : "...",
      …
    },
    "position" : 3, // position - int(1…)
    "icon" : { // icon (can be null)
      "color" : null, // color, hexadecimal format (can be null) - string(6)
      "image" : { // image (can be null)
        "name" : "icon.png", // file name - string(1…255)
        "content" : "N3R…zaA==" // content encoded in base64 - string(100…50000)
      }
    },
    "products" : [ 281, 89, … ] // products (id) that have this attribute value - int(1…)
  }
}

Response

{
    "status" : "ok"
}

Errors

Field Type Description
code AlreadyExists Attribute value code '<code>' already exists for attribute <attribute>
icon Malformed '<color>' is not a valid hexadecimal color
icon Malformed 'color' or 'image' are required
icon Malformed Both 'color' and 'image' can not be in an icon
id NotFound Attribute value <id> does not exist
image Malformed Image format '<format>' is not supported
image Malformed Image is corrupted or is not an image
image Malformed Image size can not be greater than 100 KB
image Malformed Image width and height must be less than 100 pixels
products InvalidValue Product id does not exist
products InvalidValue Product id has the attribute as variant
products Malformed A product id is repeated

attribute-values.delete

Deletes one or more attribute values.

Request

Admin SDK
Admin.api('commerce.attribute-values.delete', request, function(response) { … });
HTTP POST
/api/v10/commerce.attribute-values.delete
{
  "ids" : [ 43, 25, 108, … ] // identifiers of the attribute values to delete (required) - int(1…)
}

Response

{
  "status" : "ok"
}