Categories

Categories are a core part of organizing products and content in Sleekshop. On this page, we'll dive into the different category endpoints you can use to manage categories programmatically. We'll look at how to query, create, update, and delete categories.

The category model

The category model contains all the information about your categories, such as their name, parent category, and associated products and contents.

Properties

  • Name
    id
    Type
    integer
    Description

    Unique identifier for the category.

  • Name
    name
    Type
    string
    Description

    The name of the category.

  • Name
    prio
    Type
    integer
    Description

    The priority of the category.

  • Name
    id_parent
    Type
    integer
    Description

    The ID of the parent category. 0 if it's a root category.

  • Name
    label
    Type
    string
    Description

    The label of the category.

  • Name
    seo
    Type
    object
    Description

    SEO information for the category, including permalink, title, description, and keywords.

  • Name
    attributes
    Type
    object
    Description

    Custom attributes for the category.


POSTget_categories

List all categories

This endpoint allows you to retrieve a list of categories with the parent defined by ID.

Required attributes

  • Name
    id_parent
    Type
    integer
    Description

    The ID of the parent category.

  • Name
    language
    Type
    string
    Description

    A valid language code.

Request

POST
get_categories
curl https://demo.sleekshop.net/srv/service/ \
    -d licence_username='demo_NBSqhrcrhMci15Ir9UWI' \
    -d licence_password='s9vmrbwT23B7bmjR4Vmz' \
    -d request='get_categories' \
    -d id_parent=2 \
    -d language='en_EN'

Response

{
    "object": "shopcategories",
    "parent_category": {
        "name": "Categories",
        "prio": 2,
        "id": 2,
        "id_parent": 0,
        "label": "Categories",
        "seo": {
            "permalink": "",
            "title": "",
            "description": "",
            "keywords": "",
            "attributes": {},
            "categories": [
                {
                    "name": "Jackets",
                    "prio": 1,
                    "id": 3,
                    "id_parent": 2,
                    "label": "Jackets",
                    "seo": {
                        "permalink": "",
                        "title": "",
                        "description": "",
                        "keywords": ""
                    },
                    "attributes": {
                        "attr1": "Test"
                    }
                }
            ]
        }
    }
}

POSTget_products_in_category

Get products in category

This endpoint allows you to retrieve products contained in a category defined by its ID.

Required attributes

  • Name
    id_category
    Type
    integer
    Description

    The ID of the category.

  • Name
    language
    Type
    string
    Description

    A valid language code.

  • Name
    country
    Type
    string
    Description

    A valid country code.

Optional attributes

  • Name
    order_columns
    Type
    array
    Description

    The columns to order by.

  • Name
    order
    Type
    string
    Description

    The order of sorting (ASC or DESC).

  • Name
    left_limit
    Type
    integer
    Description

    The left limit of your selection.

  • Name
    right_limit
    Type
    integer
    Description

    The right limit of your selection.

  • Name
    needed_attributes
    Type
    array
    Description

    The attributes you want to be listed.

Request

POST
get_products_in_category
curl https://demo.sleekshop.net/srv/service/ \
    -d licence_username='demo_NBSqhrcrhMci15Ir9UWI' \
    -d licence_password='s9vmrbwT23B7bmjR4Vmz' \
    -d request='get_products_in_category' \
    -d id_category=1 \
    -d language="de_DE" \
    -d country="DE" \
    -d order_columns='["price"]' \
    -d order="DESC" \
    -d left_limit=0 \
    -d right_limit=1 \
    -d needed_attributes='["name","price"]'

Response

{
    "object": "products_in_category",
    "category": {
        "id": 1,
        "name": "Start",
        "prio": 1,
        "id_parent": 0,
        "label": "Start",
        "seo": {
            "permalink": "",
            "title": "",
            "description": "",
            "keywords": ""
        },
        "attributes": {}
    },
    "products": {
        "Schuh blau": {
            "object": "product",
            "id": 15,
            "name": "Schuh blau",
            "creation_date": "2016-03-25 14:17:46",
            "class": "colorprod",
            "seo": {
                "permalink": "blaue-laufschuhe-robust",
                "title": "Blaue Laufschuhe mit wasserdichter Oberfläche",
                "description": "Blaue Laufschuhe für Männer",
                "keywords": "blau,Schuhe,Laufschuhe"
            },
            "availability": {
                "quantity": 5,
                "quantity_warning": 3,
                "allow_override": 0,
                "active": 1
            },
            "metadata": {
                "element_number": "",
                "taxclass": {
                    "name": "Standard",
                    "calculation": "INC",
                    "value": 0.19
                },
                "length": 0,
                "width": 0,
                "height": 0,
                "weight": 0,
                "notes": ""
            },
            "attributes": {
                "name": {
                    "type": "CHAR",
                    "id": 154,
                    "name": "name",
                    "label": "Name",
                    "value": "Laufschuh blau"
                },
                "price": {
                    "type": "FLOAT",
                    "id": 157,
                    "name": "price",
                    "label": "Preis",
                    "value": 95
                }
            },
            "variations": {}
        }
    }
}

POSTcreate_category

Create a category

This endpoint allows you to create a new category in Sleekshop.

Required attributes

  • Name
    id_parent
    Type
    integer
    Description

    The ID of the parent category. Use 0 for root categories.

  • Name
    name
    Type
    string
    Description

    The name of the new category.

Optional attributes

  • Name
    labels
    Type
    object
    Description

    Labels for the category in different languages.

  • Name
    attributes
    Type
    object
    Description

    Custom attributes for the category.

  • Name
    seo
    Type
    object
    Description

    SEO information for the category.

Request

POST
create_category
curl https://demo.sleekshop.net/srv/service/ \
    -d licence_username='demo_NBSqhrcrhMci15Ir9UWI' \
    -d licence_password='s9vmrbwT23B7bmjR4Vmz' \
    -d licence_secret_key='your_secret_key' \
    -d request='create_category' \
    -d id_parent=123 \
    -d name='name_new' \
    -d labels='{"de_DE":"123321"}' \
    -d attributes='{"de_DE":{"name":"Test"}}' \
    -d seo='{"de_DE":{"permalink":"test546576"}}'

Response

{
    "object": "create_category",
    "id": "162"
}

POSTupdate_category

Update a category

This endpoint allows you to update an existing category in Sleekshop.

Required attributes

  • Name
    id_category
    Type
    integer
    Description

    The ID of the category to update.

Optional attributes

  • Name
    name
    Type
    string
    Description

    The new name for the category.

  • Name
    labels
    Type
    object
    Description

    Updated labels for the category.

  • Name
    attributes
    Type
    object
    Description

    Updated custom attributes for the category.

  • Name
    seo
    Type
    object
    Description

    Updated SEO information for the category.

Request

POST
update_category
curl https://demo.sleekshop.net/srv/service/ \
    -d licence_username='demo_NBSqhrcrhMci15Ir9UWI' \
    -d licence_password='s9vmrbwT23B7bmjR4Vmz' \
    -d licence_secret_key='your_secret_key' \
    -d request='update_category' \
    -d id_category=123 \
    -d name='name_new' \
    -d labels='{"de_DE":"123321"}' \
    -d attributes='{"de_DE":{"name":"Test"}}' \
    -d seo='{"de_DE":{"permalink":"test546576"}}'

Response

{
    "object": "update_category",
    "status": "success"
}

POSTdelete_category

Delete a category

This endpoint allows you to delete a category from your Sleekshop instance. Note: This will also remove all associations this category has with products and content.

Required attributes

  • Name
    id_category
    Type
    integer
    Description

    The ID of the category to delete.

Request

POST
delete_category
curl https://demo.sleekshop.net/srv/service/ \
    -d licence_username='demo_NBSqhrcrhMci15Ir9UWI' \
    -d licence_password='s9vmrbwT23B7bmjR4Vmz' \
    -d licence_secret_key='your_secret_key' \
    -d request='delete_category' \
    -d id_category=123

Response

{
    "object": "delete_category",
    "status": "success"
}

Was this page helpful?