departments

departments.find

Returns the departments that meet the given conditions.

Request

Admin SDK
Admin.api('commerce.departments.find', request, function(response) { … });
HTTP POST
/api/v6/commerce.departments.find
{
  "conditions" : { // returns only the departments …
    "ids" : [ 91, 66, … ], // … with these identifiers - int(1…)
    "parent" : 39, // … with this parent department (id) (can be null) - int(1…)
    "after" : 81 // … with identifier after this - 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 departments, can contain "id", "-id", "code", "-code",
                        // "name", "-name", "position" and "-position" - string
  "limit" : 10, // maximum number of departments to return - int(1…)
  "first": 30 // index of the first department to return - int(0…)
}

Response

{
  "status": "ok",
  "departments" : [ {
    "id" : 91, // identifier - int(1…)
    "code" : "SHIRTS", // code - string(0…32)
    "parent" : 39, // parent department (id) (can be null) - int(1…)
    "ancestors" : [ 12, 39 ], // ancestor departments (id) - int(1…)
    "name" : { // name - string(2) -> string(0…60)
      "en" : "Books",
      "it" : "Libri"
    },
    "description" : { // description - string(2) -> string(0…65535)
      "en" : "",
      "it" : ""
    },
    "seoTitle" : { // title for SEO - string(2) -> string(0…255)
      "en" : "",
      "it" : "",
      …
    },
    "seoKeywords" : { // keywords for SEO - string(2) -> string(0…255)
      "en" : "",
      "it" : "",
      …
    },
    "seoDescription" : { // description for SEO - string(2) -> string(0…255)
      "en" : "",
      "it" : "",
      …
    },
    "canonicalURL" : { // canonical URL - string(2) -> string(10…)
      "en" : "https://www.site.com/books",
      "it" : "https://www.site.com/it/libri",
      …
    },
    "countDepartment" : 12, // number of sub-departments - int(0…)
    "countProduct" : 4905, // total number of products contained in the department - int(0…)
    "templatePage" : "shirts.html", // template page used for the site - string(0…100)
    "position" : 3, // position (can be null) - int(1…)
    "departmentColumns" : 3, // number of columns in which the sub-departments are displayed - int(1…5)
    "productsLayout" : { // layout of the products on the department page
      "products" : 12, // number of products per page, can be 0, 12, 24, 36, 48 or 72 - int
      "columns" : 4, // columns, can be 1, 2, 3, 4 or 6 - int
      "sortOrder" : "-Price", // sort order, can be "Position", "Name", "-Name", "Price", "-Price" or "Date" - string
      "imageSize" : "Optimal", // image size, can be "Optimal", Small", "Medium" or "Large" - string
      "showDescription" : false // indicates if the description is displayed - bool
    },
    "smallImage" : { // small image (can be null)
      "url" : "http://domain/path", // url - string(53…255)
      "width" : 150, // width in pixel - int(1…2500)
      "height" : 139 // height in pixel - int(1…2500)
    },
    "largeImage" : { // large image (can be null)
      "url" : "http://domain/path", // url - string(53…255)
      "width" : 150, // width in pixel - int(1…2500)
      "height" : 139, // height in pixel - int(1…2500)
      "align" : "Left" // alignment, can be "Left", "Center" or "Right" - string
    },
    "visibility" : "Visible" // visibility, can be "Visible", "VisibleIfHasProducts" or "NotVisible" - string
  }, … ]
}

departments.get

Returns a department given its identifier.

Request

Admin SDK
Admin.api('commerce.departments.get', request, function(response) { … });
HTTP POST
/api/v6/commerce.departments.get
{
  "id" : 91, // identifier of the department (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",
  "department" : { // (can be null)
    "id" : 91, // identifier - int(1…)
    "code" : "SHIRTS", // code - string(0…32)
    "parent" : 39, // parent department (id) (can be null) - int(1…)
    "ancestors" : [ 12, 39 ], // ancestor departments (id) - int(1…)
    "name" : { // name - string(2) -> string(0…60)
      "en" : "Books",
      "it" : "Libri"
    },
    "description" : { // description - string(2) -> string(0…65535)
      "en" : "",
      "it" : ""
    },
    "seoTitle" : { // title for SEO - string(2) -> string(0…255)
      "en" : "",
      "it" : "",
      …
    },
    "seoKeywords" : { // keywords for SEO - string(2) -> string(0…255)
      "en" : "",
      "it" : "",
      …
    },
    "seoDescription" : { // description for SEO - string(2) -> string(0…255)
      "en" : "",
      "it" : "",
      …
    },
    "canonicalURL" : { // canonical URL - string(2) -> string(10…)
      "en" : "https://www.site.com/books",
      "it" : "https://www.site.com/it/libri",
      …
    },
    "countDepartment" : 12, // number of sub-departments - int(0…)
    "countProduct" : 4905, // total number of products contained in the department - int(0…)
    "templatePage" : "shirts.html", // template page used for the site - string(0…100)
    "position" : 3, // position (can be null) - int(1…)
    "departmentColumns" : 3, // number of columns in which the sub-departments are displayed - int(1…5)
    "productsLayout" : { // layout of the products on the department page
      "products" : 12, // number of products per page, can be 0, 12, 24, 36, 48 or 72 - int
      "columns" : 4, // columns, can be 1, 2, 3, 4 or 6 - int
      "sortOrder" : "-Price", // sort order, can be "Position", "Name", "-Name", "Price", "-Price" or "Date" - string
      "imageSize" : "Optimal", // image size, can be "Optimal", Small", "Medium" or "Large" - string
      "showDescription" : false // indicates if the description is displayed - bool
    },
    "smallImage" : { // small image (can be null)
      "url" : "http://domain/path", // url - string(53…255)
      "width" : 150, // width in pixel - int(1…2500)
      "height" : 139 // height in pixel - int(1…2500)
    },
    "largeImage" : { // large image (can be null)
      "url" : "http://domain/path", // url - string(53…255)
      "width" : 150, // width in pixel - int(1…2500)
      "height" : 139, // height in pixel - int(1…2500)
      "align" : "Left" // alignment, can be "Left", "Center" or "Right" - string
    },
    "visibility" : "Visible" // visibility, can be "Visible", "VisibleIfHasProducts" or "NotVisible" - string
  }
}

departments.count

Number of departments that meet the given conditions.

Request

Admin SDK
Admin.api('commerce.departments.count', request, function(response) { … });
HTTP POST
/api/v6/commerce.departments.count
{
  "conditions" : { // count only the departments …
    "ids" : [ 91, 66, … ], // … with these identifiers - int(1…)
    "parent" : 39, // … with this parent department (id) (can be null) - int(1…)
    "after" : 81 // … with identifier after this - int(0…)
  }
}

Response

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

Errors

Field Type Description
parent NotFound Department <parent> does not exist

departments.create

Creates a new department.

Request

Admin SDK
Admin.api('commerce.departments.create', request, function(response) { … });
HTTP POST
/api/v6/commerce.departments.create
{
  "department" : { // department to create (required)
    "code" : "SHIRTS", // code - string(0…32)
    "parent" : 39, // parent department (id) (can be null) - int(1…)
    "name" : { // name - string(2) -> string(0…60)
      "en" : "",
      "it" : "",
      …
    },
    "description" : { // description - string(2) -> string(0…65535)
      "en" : "",
      "it" : "",
      …
    },
    "seoTitle" : { // title for SEO - string(2) -> string(0…255)
      "en" : "",
      "it" : "",
      …
    },
    "seoKeywords" : { // keywords for SEO - string(2) -> string(0…255)
      "en" : "",
      "it" : "",
      …
    },
    "seoDescription" : { // description for SEO - string(2) -> string(0…255)
      "en" : "",
      "it" : "",
      …
    },
    "templatePage" : "shirts.html", // template page used for the site - string(0…100)
    "position" : 3, // position (can be null) - int(1…)
    "departmentColumns" : 3, // number of columns in which the sub-departments are displayed - int(1…5)
    "productsLayout" : { // products layout on the department page
      "products" : 12, // number of products per page, can be 0, 12, 24, 36, 48 or 72 - int
      "columns" : 4, // columns, can be 1, 2, 3, 4 or 6 - int
      "sortOrder" : "-Price", // sort order, can be "Position", "Name", "-Name", "Price", "-Price" or "Date" - string
      "imageSize" : "Optimal", // image size, can be "Optimal", Small", "Medium" or "Large" - string
      "showDescription" : false // indicates if the description is displayed - bool
    },
    "visibility" : "Visible" // visibility, can be "Visible", "VisibleIfHasProducts" or "NotVisible" - string
  }
}

Response

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

Errors

Field Type Description
parent NotFound Department <parent> does not exist
parent InvalidValue Department <parent> is at the last level
templatePage InvalidValue '<templatePage>' is not a valid template page

departments.update

Updates a department. Any fields left out of the request will remain unchanged.

Request

Admin SDK
Admin.api('commerce.departments.update', request, function(response) { … });
HTTP POST
/api/v6/commerce.departments.update
{
  "id": 91, // identifier of the department to update (required) - int(1…)
  "department" : { // department's fields to update (required)
    "code" : "SHIRTS", // code - string(0…32)
    "name" : { // name - string(2) -> string(0…60)
      "en" : "",
      "it" : "",
      …
    },
    "description" : { // description - string(2) -> string(0…65535)
      "en" : "",
      "it" : "",
      …
    },
    "seoTitle" : { // title for SEO - string(2) -> string(0…255)
      "en" : "",
      "it" : "",
      …
    },
    "seoKeywords" : { // keywords for SEO - string(2) -> string(0…255)
      "en" : "",
      "it" : "",
      …
    },
    "seoDescription" : { // description for SEO - string(2) -> string(0…255)
      "en" : "",
      "it" : "",
      …
    },
    "templatePage" : "shirts.html", // template page used for the site - string(0…100)
    "position" : 3, // position (can be null) - int(1…)
    "departmentColumns" : 3, // number of columns in which the sub-departments are displayed - int(1…5)
    "productsLayout" : { // products layout on the department's page
      "products" : 12, // number of products per page, can be 0, 12, 24, 36, 48 or 72 - int
      "columns" : 4, // columns, can be 1, 2, 3, 4 or 6 - int
      "sortOrder" : "-Price", // sort order, can be "Position", "Name", "-Name", "Price", "-Price" or "Date" - string
      "imageSize" : "Optimal", // image size, can be "Optimal", Small", "Medium" or "Large" - string
      "showDescription" : false // indicates if the description is displayed - bool
    },
    "smallImage" : { // small image (can be null)
      "name" : "small.png", // file name - string(1…255)
      "content" : "N3R…zaA==" // content encoded in base64 - string
    },
    "largeImage" : { // large image (can be null)
      "name" : "large.jpg", // file name - string(1…255)
      "content" : "N3R…zaA==" // content encoded in base64 - string
    },
    "largeImageAlign" : "Left", // alignment of the large image, can be "Left", "Center" or "Right" - string
    "visibility" : "Visible" // visibility, can be "Visible", "VisibleIfHasProducts" or "NotVisible" - string
  }
}

Response

{
  "status" : "ok"
}

Errors

Field Type Description
id NotFound Department <id> does not exist
largeImage Malformed Image width and height must be less than 2500 pixels
largeImage Malformed File format is not a valid or supported format
smallImage Malformed Image width and height must be less than 2500 pixels
smallImage Malformed File format is not a valid or supported format
templatePage InvalidValue '<templatePage>' is not a valid template page

departments.delete

Deletes one o more departments. Departments with sub-departments or products are not deleted.

Request

Admin SDK
Admin.api('commerce.departments.delete', request, function(response) { … });
HTTP POST
/api/v6/commerce.departments.delete
{
  "ids" : [ 91, 66, … ] // identifiers of the departments to delete (required) - int(1…)
}

Response

{
  "status" : "ok"
}

Errors

Field Type Description
ids InvalidValue Department <id> contains subdepartments
ids InvalidValue Department <id> contains products
`