cancel
Showing results for 
Search instead for 
Did you mean: 

Backoffice commerce search perspective no longer available when logging in to backoffice as a customer support administrator.

Former Member
0 Kudos

We need for our Employee users to be able to have access to both the Customer Support perspective and the Commerce Search perspective in backoffice, but I cannot find a way to have both of these options present in the chooser at the same time.

Is it possible to configure a group that will enable both of these perspectives as options for a user in this group?

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member673804
Discoverer
0 Kudos

Hi ,

To force backoffice to use configuration of perspective chooser from your custom extension you have to do the next steps:

  1. Create a class:

    package mybackoffice.widgets.perspectivechooser.perspectiveresolver;

      import java.util.Objects;
         
         import org.apache.log4j.Logger;
         
         import com.hybris.backoffice.widgets.perspectivechooser.perspectiveresolver.AuthorityGroupDefaultPerspectiveResolver;
         import com.hybris.cockpitng.config.perspectivechooser.jaxb.PerspectiveChooser;
         import com.hybris.cockpitng.core.config.CockpitConfigurationException;
         import com.hybris.cockpitng.core.config.CockpitConfigurationNotFoundException;
         import com.hybris.cockpitng.core.config.CockpitConfigurationService;
         import com.hybris.cockpitng.core.config.ConfigContext;
         import com.hybris.cockpitng.core.config.impl.DefaultConfigContext;
         import com.hybris.cockpitng.core.user.AuthorityGroupService;
         import com.hybris.cockpitng.core.user.CockpitUserService;
         import com.hybris.cockpitng.core.user.impl.AuthorityGroup;
         
         public class MyAuthorityGroupDefaultPerspectiveResolver extends AuthorityGroupDefaultPerspectiveResolver {
         
             private static final Logger LOG = Logger.getLogger(MyAuthorityGroupDefaultPerspectiveResolver.class);
         
             private static final String COMPONENT_NAME = "perspective-chooser";
             private static final String MODULE_ATTRIBUTE = "module";
         
             private final CockpitConfigurationService cockpitConfigurationService;
             private final CockpitUserService cockpitUserService;
             private final AuthorityGroupService authorityGroupService;
             private final String module;
         
             public MyAuthorityGroupDefaultPerspectiveResolver(final CockpitConfigurationService cockpitConfigurationService, final CockpitUserService cockpitUserService,
                                                                   final AuthorityGroupService authorityGroupService, final String module) {
                 super(cockpitConfigurationService, cockpitUserService, authorityGroupService);
                 this.cockpitUserService = cockpitUserService;
                 this.authorityGroupService = authorityGroupService;
                 this.cockpitConfigurationService = cockpitConfigurationService;
                 this.module = module;
             }
         
             protected PerspectiveChooser loadPerspectiveChooserConfig() {
                 PerspectiveChooser config = null;
                 try {
                     config = getCockpitConfigurationService().loadConfiguration(buildPerspectiveChooserContext(), PerspectiveChooser.class);
                     if (config == null) {
                         LOG.warn("Cannot retrieve perspective chooser widget configuration");
                     }
                 } catch (CockpitConfigurationNotFoundException e) {
                     if (LOG.isDebugEnabled()) {
                         LOG.warn("No config found for current user.", e);
                     }
                 } catch (CockpitConfigurationException e) {
                     LOG.warn("Cannot retrieve perspective chooser widget configuration", e);
                 }
                 return config;
             }
         
             protected ConfigContext buildPerspectiveChooserContext() {
                 final DefaultConfigContext context = new DefaultConfigContext();
                 context.setPrincipal(getPrincipalId());
                 context.setComponent(getComponentName());
                 context.addAttribute(MODULE_ATTRIBUTE, getModule());
                 return context;
             }
         
             protected String getPrincipalId() {
                final String currentUser = getCockpitUserService().getCurrentUser();
                final AuthorityGroup authorityGroup = getAuthorityGroupService().getActiveAuthorityGroupForUser(currentUser);
                return Objects.nonNull(authorityGroup) ? authorityGroup.getCode() : currentUser;
             }
         
             protected static String getComponentName() {
                 return COMPONENT_NAME;
             }
         
             protected String getModule() {
                 return module;
             }
         
             protected CockpitConfigurationService getCockpitConfigurationService() {
                 return cockpitConfigurationService;
             }
         
             protected CockpitUserService getCockpitUserService() {
                 return cockpitUserService;
             }
         
             protected AuthorityGroupService getAuthorityGroupService() {
                 return authorityGroupService;
             }
         }
     
    
  2. Create a bean for this class in yourbackofficeextension-backoffice-spring.xml:

      <bean id="defaultMyAuthorityGroupDefaultPerspectiveResolver" class="mybackoffice.widgets.perspectivechooser.perspectiveresolver.MyAuthorityGroupDefaultPerspectiveResolver">
             <constructor-arg name="cockpitUserService" ref="cockpitUserService"/>
             <constructor-arg name="cockpitConfigurationService" ref="cockpitConfigurationService"/>
             <constructor-arg name="authorityGroupService" ref="authorityGroupService"/>
             <constructor-arg name="module" value="**yourbackofficeextension**" />
         </bean>
     
         <alias alias="perspectiveResolvers" name="myPerspectiveResolvers"/>
         <util:set id="myPerspectiveResolvers" set-class="java.util.LinkedHashSet">
             <ref bean="defaultMyAuthorityGroupDefaultPerspectiveResolver" />
             <bean class="com.hybris.backoffice.widgets.perspectivechooser.perspectiveresolver.AuthorityGroupDefaultPerspectiveResolver">
                 <constructor-arg name="cockpitUserService" ref="cockpitUserService"/>
                 <constructor-arg name="cockpitConfigurationService" ref="cockpitConfigurationService"/>
                 <constructor-arg name="authorityGroupService" ref="authorityGroupService"/>
             </bean>
             <bean class="com.hybris.backoffice.widgets.perspectivechooser.perspectiveresolver.SequenceDefaultPerspectiveResolver"/>
             <bean class="com.hybris.backoffice.widgets.perspectivechooser.perspectiveresolver.TreePerspectiveResolver">
                 <constructor-arg name="cockpitConfigurationService" ref="cockpitConfigurationService"/>
                 <constructor-arg name="resourceLoader" ref="widgetResourceReader"/>
             </bean>
         </util:set>
    
    

Replace yourbackofficeextension value with name of your custom backoffice extension

Regards,

Oleg

0 Kudos

Thanks for the much needed help!! Is there any documentation for these available in wiki, as I was not able to find them there.

former_member673804
Discoverer
0 Kudos

There is no information about this on hybris wiki 😞 I found the solution during backoffice code debugging

former_member620692
Active Contributor
0 Kudos

Hi - I would appreciate your upvoting this answer if you liked it or it fulfilled your requirement.

We (the s) should treat it as our responsibility to accept/upvote the correct answers. An accepted answer helps everyone (the questioner gets +10 points, answerer gets +15 points and other s can easily locate and use an accepted answer with confidence).

0 Kudos

Hi

I am facing the similar issue, Observed that in direct-config.xml from orchestrator mode, contains the OOTB module=customersupportbackoffice code for customersupportadministratorrole which does not contain this perspective, whereas my custom module contains the newly added perspective for the same role and both are present in this xml file, but still it takes OOTB code as preference over my custom code.

Snippet - If I remove the OOTB code, then preference comes to my custom code and perspective is taken into consideration.

Any help on how to give preference to my custom code over OOTB code when both are present, as merge attributes are also not working on the context here.

Cheers

former_member638520
Contributor
0 Kudos

According to https://help.hybris.com/6.0.0/hcd/8b69f102866910149bf0e4e6649259f6.html

section: Available Perspectives Configuration

it's possible to define which perspectives should be available for given authority group. Probably your configuration looks like:

   <context principal="customersupportadministratorrole" component="perspective-chooser" module="customersupportbackoffice">
     <y:perspective-chooser xmlns:y="http://www.hybris.com/cockpitng/config/perspectiveChooser">
       <y:authority name="customersupportadministratorrole">
         <y:perspective id="CustomerSupport-Perspective"/>
         <y:perspective id="hmc2"/>
             </y:authority>
         </y:perspective-chooser>
   </context>


Therefore, in order to add a new perspective you have to change cockpit-config.xml Nevertheless, before you start chainging cockpit-config.xml, you can check if it works in orchestrator mode. Open 'show cockpit-config.xml' and filter out xml by component type (perspective-chooser). Next, add this line

         <y:perspective id="commerceSearch"/>

as a child of

         <y:authority name="customersupportadministratorrole">

Then, save changes and log in as CustomerSupportAdministrator.

Regards

Lukasz

Former Member
0 Kudos

Hi Lukasz,

is there any way to hide this for a particular user group ? i'm using 5.7 hybris

former_member638520
Contributor
0 Kudos

Hi

In orchestrator mode (F4) you can check that customer support perspective is available for one of the following roles (access restriction tab in border layout for customersupport_backoffice_perspective_name): customersupportadministratorrole, customersupportmanagerrole, customersupportagentrole, backofficeadmin

Therefore, you can add appropriate authority group (for example customersupportagentrole) to given user group:

Regards

Lukasz

Former Member
0 Kudos

I am not able to reproduce your screen shot. Where can I add authorities to a group?

former_member638520
Contributor
0 Kudos

User -> User Groups -> Select a group -> Administration tab

Former Member
0 Kudos

I am using version 6.0 and I don't see the authorities option for a group. Is this not available in 6.0?

Former Member
0 Kudos

Oh I see. The group has to be of type BackofficeRole. Thank you

Former Member
0 Kudos

So my issue is that the commerce search perspective disappears when I log in as a customer support administrator. Do you know how I can have Commerce Search AND Customer Support as options in the chooser in backoffice?