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
- $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
$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”
- <!-- --!>
- 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
<!-- --!> 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
Could you please explain how to implement action restrictions in eshop
For example if i need to prevent adding products to cart does this concept helpful ?
Hi can u plz upload a how to do a promotions and create a custom promotions in hybris …..
Hi can u plz upload restrictions on cart aso
Please upload cart restriction on usergroup
Try to restrict add to cart component similar to above for the group which you need
Can we apply restriction on CMSLinkComponent. If yes how?
Yes, above example has it “LoginLink”
I created a CMSUserGroupRestiriction to hide AddToCart button .
# CMS User Group Restrictions
INSERT_UPDATE CMSUserGroupRestriction;$contentCV[unique=true];uid[unique=true];name;userGroups(uid);includeSubgroups;components(&componentRef)
;;ProductAddToCartComponentRestriction;Product AddToCart Component Restriction;b2bMyHECViewGroup;true;ProductAddToCartComponent
But its not working. IS there any mistake