Restricting wcms component or page in hybris

Restrictions specify rules for when a page or component should not be displayed

We can restrict a page or component from being displayed to specified users or user groups, on specified dates etc..

There are different types of restrictions like user restriction, user group restriction, time restriction etc..

We can apply restriction either to a page or to a component.

We can apply restriction through impex or directly through CMS Cockpit.

Steps to apply restriction on pages/components

Step 1
Define new CMS Restriction and provide the reference of page/component on which restriction has to be applied

  1. $contentCatalog=myStoreContentCatalog
  2. $contentCV=catalogVersion(CatalogVersion.catalog(Catalog.id[default=$contentCatalog]),CatalogVersion.version[default=Staged])[default=$contentCatalog:Staged]
  3. INSERT_UPDATE CMSUserRestriction;$contentCV[unique=true];uid[unique=true];name;users(uid);components(&componentRef);&componentRef
  4. ;;AnonymousUserRestriction;Anonymous User Restriction;anonymous;LoginLink;AnonymousUserRestriction
$contentCatalog=myStoreContentCatalog
$contentCV=catalogVersion(CatalogVersion.catalog(Catalog.id[default=$contentCatalog]),CatalogVersion.version[default=Staged])[default=$contentCatalog:Staged]
INSERT_UPDATE CMSUserRestriction;$contentCV[unique=true];uid[unique=true];name;users(uid);components(&componentRef);&componentRef
;;AnonymousUserRestriction;Anonymous User Restriction;anonymous;LoginLink;AnonymousUserRestriction


In the above impex, user restriction applied on the component called “LoginLink” and user on which this restriction has been applied is specified by user’s uid “anonymous”

  1. <!--            --!>
  2. INSERT_UPDATE CMSUserGroupRestriction;$contentCV[unique=true];uid[unique=true];name;userGroups(uid);includeSubgroups;components(&linkRef)
  3. ;;MyAccountLinkApproverGroupRestriction;My Account Link Approver Group Restriction;b2bapprovergroup;true;ApprovalDashboardLink
<!--            --!>
INSERT_UPDATE CMSUserGroupRestriction;$contentCV[unique=true];uid[unique=true];name;userGroups(uid);includeSubgroups;components(&linkRef)
;;MyAccountLinkApproverGroupRestriction;My Account Link Approver Group Restriction;b2bapprovergroup;true;ApprovalDashboardLink


In the above impex, user group restriction applied on the component called “ApprovalDashboardLink” and user group on which this restriction has been applied is specified by user group uid “b2bapprovergroup”

Step 2
Import the impex

Step 3
Synchronize the content catalog so that restriction is available in online catalog.

Similarly, we can provide page UIDs to apply restriction on pages like how we have done for components

Note : We can also create action restrictions to restrict certain actions like “Add to Cart”  “View Order” etc

About the Author

Founder of javainsimpleway.com
I love Java and open source technologies and very much passionate about software development.
I like to share my knowledge with others especially on technology 🙂
I have given all the examples as simple as possible to understand for the beginners.
All the code posted on my blog is developed,compiled and tested in my development environment.
If you find any mistakes or bugs, Please drop an email to kb.knowledge.sharing@gmail.com

Connect with me on Facebook for more updates

Share this article on