# Productgroups

*This describes* [*Product Group schema version 1.1*](https://mbintegrationdataprod.blob.core.windows.net/schemas/productGroups-v1.1.xsd)*.*

Product groups is used for creating a hierarchy of products. It makes it easier for the users to do the search by brand or by product type. Much like pricelists, product groups are not inherited along the customer tree automatically, only stores that subscribe to the the product groups can see them.

## Usage

### Subscriptions

Managing the product group subscriptions cannot currently be done through the API, it needs to be done through Mediablob.

Subscribing to product groups is all or nothing, the store either has access to the full set of product groups, or none at all.

### Function call

Use the function call *UploadProductGroupsXml* to upload your product group xml.

### Structure

The product groups are a hierarchy where each group can contain a number of subgroups, which in turn can have their own subgroups, etc. Each group must have its own unique ID. Shoppa places no particular restrictions on these ID:s, so we recommend that you mirror existing ID:s in whichever system you are using. Each group must also contain at least one text element, specifiying the name of the group. The group names can be specified by language, so that different users can have different group names, but bear in mind that the group structure and its contents will be the same.

The full definition of the product groups is done in two parts: first the structure is defined as per above, and then the products are assigned to their groups using the groups ID. Note that a product can belong to multiple groups.

```markup
<?xml version="1.0" encoding="UTF-8"?>
<productGroups customerID="" customerIDType="" createDate="2016-08-25T01:01:33Z" xmlns="http://shoppa.com/productGroupsSchema">
    <groups>
        <group id="">
            <texts>
                <text languageCode="" name="" />
            </texts>
            <groups>
                <group id="">
                    <texts>
                        <text languageCode="" name="" />
                        <text languageCode="" name="" />
                    </texts>
                </group>
            </groups>
        </group>
    </groups>
    <products>
        <product id="" idType="">
            <group ref="" />
            <group ref="" />
        </product>
    </products>
</productGroups>
```

### Changing the structure

The group structure cannot be edited. If a change is required you need to send the entire structure again. Note that products can still be added to groups without having to resend the entire structure.

## Examples

### Basic product groups

```markup
<?xml version="1.0" encoding="UTF-8"?>
<productGroups customerID="1143" customerIDType="ShoppaID" createDate="2019-08-25T01:01:33Z" xmlns="http://shoppa.com/productGroupsSchema">
    <groups>
        <group id="1">
            <texts>
                <text languageCode="xx" name="Gardening" />
            </texts>
        </group>
        <group id="2">
            <texts>
                <text languageCode="xx" name="Interior decoration" />
            </texts>
        </group>
        <group id="3">
            <texts>
                <text languageCode="xx" name="Plumbing" />
            </texts>
        </group>
    </groups>
    <products>
        <product id="91234" idType="Code1">
            <group ref="1" />
        </product>
        <product id="92345" idType="Code1">
            <group ref="2" />
        </product>
        <product id="93456" idType="Code1">
            <group ref="3" />
        </product>
    </products>
</productGroups>
```

### Nested groups with multiple languages

```markup
<?xml version="1.0" encoding="UTF-8"?>
<productGroups customerID="1143" customerIDType="ShoppaID" createDate="2016-08-25T01:01:33Z" xmlns="http://shoppa.com/productGroupsSchema">
    <groups>
        <group id="1">
            <texts>
                <text languageCode="xx" name="Plants" />
                <text languageCode="sv-SE" name="Växter" />
                <text languageCode="no-NO" name="Planter" />
            </texts>
            <groups>
                <group id="11">
                    <texts>
                        <text languageCode="xx" name="Vegetables" />
                        <text languageCode="sv-SE" name="Grönsaker" />
                        <text languageCode="no-NO" name="Grønnsaker" />
                    </texts>
                </group>
                <group id="12">
                    <texts>
                        <text languageCode="xx" name="Flowers" />
                        <text languageCode="sv-SE" name="Blommor" />
                        <text languageCode="no-NO" name="Blomster" />
                    </texts>
                    <groups>
                        <group id="121">
                            <texts>
                                <text languageCode="xx" name="Perennials" />
                                <text languageCode="sv-SE" name="Perenner" />
                                <text languageCode="no-NO" name="Stauder" />
                            </texts>
                        </group>
                        <group id="122">
                            <texts>
                                <text languageCode="xx" name="Annuals" />
                                <text languageCode="sv-SE" name="Annueller" />
                                <text languageCode="no-NO" name="Årbøker" />
                            </texts>
                        </group>
                    </groups>
                </group>
            </groups>
        </group>
        <group id="2">
            <texts>
                <text languageCode="xx" name="Gardening tools" />
                <text languageCode="sv-SE" name="Trädgårdsverktyg" />
                <text languageCode="no-NO" name="Hageredskap" />
            </texts>
        </group>
    </groups>
    <products>
        <product id="91234" idType="Code1">
            <group ref="11" />
            <group ref="12" />
        </product>
        <product id="92345" idType="Code1">
            <group ref="12" />
        </product>
        <product id="93456" idType="Code1">
            <group ref="121" />
        </product>
        <product id="94567" idType="Code1">
            <group ref="122" />
        </product>
        <product id="95678" idType="Code1">
            <group ref="2" />
        </product>
    </products>
</productGroups>
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://shoppa.gitbook.io/knowledge-hub/api-documentation/xml-structure/productgroups.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
