Use restrictions in SAP Hybris

Hybris Logo

1. Overview

A restriction in Hybris is a set of rules applied to flexible searches in order to limit the search results based on certain specific conditions.

This is a simplified version of how restrictions work in Hybris.


Overview restrictions in SAP Hybris

By default, restrictions are not applied on admingroup members, admin will always get the full results.

This article will guide through how to create and use restrictions in Hybris.

2. Restrictions in action

2.1. Create restriction

First of all, you will need to create an instance of the SearchRestrictionModel using impex or HMC/Backoffice as shown below.

INSERT_UPDATE SearchRestriction	;code[unique=true]			;name[lang=en]					;principal(UID)	;restrictedType(code)	;active	;generate	;query
								;customerWithoutAnonymous	;Customer Anonymous Restriction	;employeegroup	;Customer				;true	;true		;{uid} NOT LIKE 'anonymous'
  • code: Unique id code of the restriction.
  • name: Name of the restriction.
  • principal: User/user group to whom the restriction will be applied.
  • restrictedType: Item type to which the restriction will be applied on.
  • active: true means the restriction is enabled, false is disabled.
  • query: conditions to be added to the WHERE clause of the flexible search.

2.2. Use restriction

When you run a flexible search query on CustomerModel as a User who belongs to the employeegroup.

SELECT {pk}, {uid} FROM {Customer}

The restriction query will systematically be added to the flexible search.

SELECT {pk}, {uid} FROM {Customer} WHERE {uid} NOT LIKE 'anonymous'

2.3. Test restriction on hac (hybris administration console)

Navigate to hac  -> Console -> FlexibleSearch, add your flexibleSearch, employee account uid and run.

Test restrictions on hac



5 2 votes
Article Rating
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x