Category Management in TYRIOS pim
Beschreibung:
A central element to manage products in TYRIOS pim is the category system. It is a hierarchical tree structure with one root node. A product can be assigned to as many categories as you want.
Authentication
The API endpoints of TYRIOS are only available for authorized users. Therefore, the user must be authenticated. There are two different authentication types:
- Authentication by BASIC authentication. The user account must have an activated REST API token. You need to send an appropriate BASIC authentication header.
- Authentication by mobile app registration. You need to send an appropriate app registration token.
Required rights
To use this API, you need to have user credentials with category management rights. If you don't have these rights, you will get a 403 error code. The API is not available for external users without credentials.
Data structure
Shop categories are managed with ShopCategoryData structures. The ShopCategoryData is a nested sets data structure to support fast tree reads. That means, every ShopCategoryData has three fields:
- nodeLeft
- nodeRight
- nodeLevel
With these fields, it is possible to request any subtree with only one SQL statement.
In addition to the ShopCategoryData, you might want to assign preview images to a category. This is done by assigning a MediahelperFile object.
Listing categories
To request a product, you need to call the GET endpoint
https://[instance]/service/ProductManagement/products
The request supports several GET parameters:
- offset: offset of the product list, default 0
- length: number of products provided, default 20,
- filter: JSON object to filter for a specific fields. All product data fields are supported.
- sorting: JSON object with field: ASC/DESC sorting definition
A request to filter based on material number will look like this:
https://[instance]/service/ProductManagement/products/?offset=0&length=5&filter={%22materialNumber%22:%221%22}&sorting={%22name_de%22:%22ASC%22}
You will retrieve the following data structure
{ "products": [ { "id": 90, "name_de": "Neuer Name De", "shortDescription_de": "Kurzbeschreibung", "description_de": "Beschreibung", "price": 1.33, "ShopCategoryData": [ { "id": 1, .... } ], "mainMediaFile": {id: 136,...}, "MediahelperFile": [ {id: 136,...} ] .... } ], "count":20 }
The products are in the products fields, the count field gives you the information how many items are found.
Please be aware, that the concrete data structure depends on the instance as TYRIOS is an aspect oriented system.
get one specific category
You can request a specific product by using the GET endpoint
https://[instance]/service/ProductManagement/product/[productID]
You will, if the product exists, get a full data object for the product data
{ "id": 90, "name_de": "Neuer Name De", "shortDescription_de": "Kurzbeschreibung", "description_de": "Beschreibung", "price": 1.33, "ShopCategoryData": [1,14], "mainMediaFile": 129, "MediahelperFile": [136,129] .... }
Create / update a category
You can create and update products using the same endpoint. You need to send a POST request.
https://[instance]/service/ProductManagement/product
If the id is not null, the system assumes that it needs to update an existing product. Else it creates a new one.
As payload, you only need to send a complete product object. In case you update an existing product, not provided fields are assumed to be empty.
{ "id": 90, "name_de": "Neuer Name De", "shortDescription_de": "Kurzbeschreibung", "description_de": "Beschreibung", "price": 1.33, "ShopCategoryData": [1,14], "mainMediaFile": 129, "MediahelperFile": [136,129] .... }
Reference objects can be provided as object or by id.
Please keep in mind that the available fields depend on the instance. So it is not possible to describe the complete structure in this documentation.
Delete a category
If you want to delete a category and all sub categories, you need to send a DELETE request to the endpoint
https://[instance]/service/ShopCategoryManagement/category/[categoryD]