User Groups
User groups can be used to define segments of users, such as signed-out users, signed-in users, or users associated with specific business roles or partners. These groups are configured during product import to control:
- which products are visible to specific user groups
- whether product data (e.g., prices) should differ between user groups
To define which products should be included or excluded for specific user groups, use the following structure in your product JSON:
"settings": {
"includeUserGroups": [
"23",
"42"
],
"excludeUserGroups": [
"64"
]
},
includeUserGroups ensures this particular product is shown only to users from groups 23 and 42, and hidden from all others. excludeUserGroups hides this particular product from users in group 64, while making it visible to all everyone else. It is not necessary to use both at the same time.
To assign different values—such as prices—for different user groups, send the price attribute like this:
{
"key": "price",
"value":"9,98 EUR",
"userGroups": ["42","7"]
},
{
"key": "price",
"value":"7,99 EUR",
"userGroups":["9"]
}
Always include a default value for any attribute with user group-specific values. Here is an example of how you would define a default price:
{
"key": "price",
"value":"9,99 EUR"
}
In addition to providing user-group specific data during product import, you can set a user group in your search requests to ensure the search response is adjusted to fit that user group. For example, let's imagine a specific product is only available to users in groups 23 and 42, and user group 42 has a special price. Here is what might happen:
- sending user group 42 in the search query will return that product and display the special price
- sending user group 23 will show that product, but with the default price
- sending user group 9 will hide that product