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 3 votes
Article Rating
Subscribe
Notify of
guest

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

2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Mykola
Mykola
11 months ago

Please tell me whether Hybris applies restrictions for types used in subqueries. Thanks

Shailesh
Shailesh
11 months ago

Good work Could you please create one post on how to use referenceSearchCondition in tag in *backoffice-config.xml The requirement is I want to filter the products in search dropdown in wizet based on user level brands for extracting selected products in excel file. I have written code for getting list of brands brands in backend list of as List and returned from custom service but need to know how to map service returned List with ProductModel in which having one attribute as set getBrands() and in BrandModel having one attribute brandCode as String where I want to do exact match,… Read more »

2
0
Would love your thoughts, please comment.x
()
x