departments

departments.find

Returns the departments in a parent department.

JS
CR.api('commerce.departments.find', request, function(response) { … });
HTTP
POST /open2b/api/v3/commerce.departments.find

request

{
  "parent" : 39, // parent department (id) - 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…100)
  "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) - int(0…)
    "parents" : [ { // parent departments
      "id" : 12, // identifier - int(1…)
      "name" : { // name - string(2) -> string(0…60)
        "en" : "Woman",
        "it" : "Donna"
      }
    }, {
      "id" : 39, // identifier - int(1…)
      "name" : { // name - string(2) -> string(0…60)
        "en" : "Dresses",
        "it" : "Vestiti"
      }
    }, … ],
    "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" : ""
    },
    "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" - 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
    }
  }, … ]
}

departments.get

Returns a department given its identifier.

JS
CR.api('commerce.departments.get', request, function(response) { … });
HTTP
POST /open2b/api/v3/commerce.departments.get

request

{
  "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) - int(0…)
    "parents" : [ { // parent departments
      "id" : 12, // identifier - int(1…)
      "name" : { // name - string(2) -> string(0…60)
        "en" : "Woman",
        "it" : "Donna"
      }
    }, {
      "id" : 39, // identifier - int(1…)
      "name" : { // name - string(2) -> string(0…60)
        "en" : "Dresses",
        "it" : "Vestiti"
      }
    }, … ],
    "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" : ""
    },
    "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" - 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
    }
  }
}

departments.count

Total number of departments or the children in a parent department.

JS
CR.api('commerce.departments.count', request, function(response) { … });
HTTP
POST /open2b/api/v3/commerce.departments.count

request

{
  "parent" : 91 // parent department (id) - 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.

JS
CR.api('commerce.departments.create', request, function(response) { … });
HTTP
POST /open2b/api/v3/commerce.departments.create

request

{
  "department" : { // department to create (required)
    "code" : "SHIRTS", // code - string(0…32)
    "parent" : 39, // parent department (id) (required) - int(0…)
    "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" - string
      "imageSize" : "Optimal", // image size, can be "Optimal", Small", "Medium" or "Large" - string
      "showDescription" : false // indicates if the description is displayed - bool
    }
  }
}

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 not 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.

JS
CR.api('commerce.departments.update', request, function(response) { … });
HTTP
POST /open2b/api/v3/commerce.departments.update

request

{
  "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" - 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
  }
}

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.

JS
CR.api('commerce.departments.delete', request, function(response) { … });
HTTP
POST /open2b/api/v3/commerce.departments.delete

request

{
  "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