cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Select Different CatalogVersion in PCM Backoffice on Load

pratik_a_soni
Participant
1,494

By default PCM Backoffice loads with all the products populated in the result area. We want to restrict it to only show the Staged catalogVersion products. What will be the right way to do this.

Basically we want a different Catalog Version selected by default in the Catalog Selector.

We use SOLR in our PCM Backoffice.

Accepted Solutions (1)

Accepted Solutions (1)

former_member625836
Active Contributor

Hi ,

I'm afraid that there is no such feature ootb. What you could do it to either extend Catalog Selector widget and replace it or create a simple widget that would send a selection context on initialization to select specified catalog version. If so - please bear in mind that you have to send this message after all widgets are initialized! To be sure of it you should use com.hybris.cockpitng.util.UITools#postponeExecution.

Cheers, Jacek

pratik_a_soni
Participant
0 Likes

Thanks Jacek for your inputs.

I did some more digging and found that if I can get the reference of this class com.hybris.cockpitng.widgets.common.explorertree.ExplorerTreeController then I can call handleExternalNodeIdSelection() method by passing my required nodeId this.getTreeModel().getRoot().getId() + "_catalogs_" + catalog.getName() + catalogVersion.getVersion(). The nodeId will be something like _y_et_root__catalogs_Catalog NameStaged.

It would be interesting to know how can I get this reference and how can I call this method at the end when the page loads.

Thanks

former_member625836
Active Contributor
0 Likes

Well... It may also work, yet I wouldn't go this way. May recommendation would be as mentioned above. Personally I would prefer creating simple widget that in initialize method searches for particular catalog, wraps it into selection context and then calls com.hybris.cockpitng.util.UITools#postponeExecution to eventually send this context via socket connected to selectionContext socket of Explorer Tree.

Cheers, Jacek

former_member625836
Active Contributor
0 Likes

Well... It may also work, yet I wouldn't go this way. May recommendation would be as mentioned above. Personally I would prefer creating simple widget that in initialize method searches for particular catalog, wraps it into selection context and then calls com.hybris.cockpitng.util.UITools#postponeExecution to eventually send this context via socket connected to selectionContext socket of Explorer Tree.

Cheers, Jacek

pratik_a_soni
Participant
0 Likes

Hi Jacek,

I tried your suggestion. Though I'm running out of luck here. The selection is not happening properly this way. Maybe the postpone event is not getting triggered at right time or I'm missing something. Just to let you know this below code is getting invoked properly within the flow, just that the selection is not happening.

Can you suggest me how can I send a selection context?

 public class MyExplorerTreeController extends ExplorerTreeController
 {
 
     @Override
     public void initialize(final Component comp)
     {
         super.initialize(comp);
 
         UITools.postponeExecution(comp, new Executable()
         {
             @Override
             public void execute()
             {
                 final NavigationNode node = findNodeById(getTreeModel().getRoot(), "_y_et_root__catalogs_" + "ctlg_id : ver_id");
 
                 final Event event = new Event("manual selection event", null, node);
                 final Treeitem treeItem = new Treeitem("", node);
                 handleTreeSelection(event, treeItem);
             }
         });
     }
 }
former_member625836
Active Contributor
0 Likes

I would expect it to work...

You would have to do the following: 1. Define completely new widget (let's call it sap.commerce.catalog.init.selector) 2. Put new widget in mesh-up (let's say under catalog-init id) 3. Widget should define one output socket of type com.hybris.backoffice.navigation.TreeNodeSelector (let's call it initialCatalogVersion) 4. A connection should be defined: catalog-init:initialCatalogVersion -> pcmbackoffice-collectionBrowser-catalogFilterTree:nodeIdSelected 5. In new widgets controller:

 @Override
      public void initialize(final Component comp)
      {
          super.initialize(comp);
  
          UITools.postponeExecution(comp, new Executable()
          {
              @Override
              public void execute()
              {
                  final String nodeId = getTreeModel().getRoot(), "_y_et_root__catalogs_" + "ctlg_id : ver_id";
                  final TreeNodeSelector selector = new TreeNodeSelector(nodeId, true);
                  getWidgetInstanceManager().sendOutput("initialCatalogVersion", selector);
              }
          });
      }


Cheers, Jacek

pratik_a_soni
Participant
0 Likes

I followed your approach and it behaved the same way as to what I did. But your approach was clear and precise so I kept it.

I figured out the main culprit of why even after selecting the catalog version the search results were showing products from both catalogs.

"pcmbackoffice-search-init" widget was getting invoked at the time of login which was causing the results to display from all available catalogs. Since in hybris 6.7 I cannot remove the widget-connection, so I removed this widget itself and everything started working great.

I validated and it looks good. Let me know if you've any issues with this approach. I'm marking this thread as answered and thank you very much for the support.

Cheers Pratik

former_member625836
Active Contributor
0 Likes

Sound good to me! I'm glad I could help.

0 Likes

Hi,

I've removed the pcmbackoffice-search-init widget but I'm still getting the "All Catalogs" being rendered before selection...

What could be missing?

Thanks

Answers (1)

Answers (1)

tzillinger
Explorer
0 Likes

One question wouldn't restricting the read permissions for other catalogs (for certain usergroups) work either?

 $productCatalog = SomeCatalog
 $productCatalogVersion = SomeStagedVersion
 $productCatalogVersionOnline = SomeOnlineVersion
 # create test CatalogVersion
 INSERT_UPDATE CatalogVersion; catalog(id)[unique = true]; version[unique = true]; active[default = false]; mnemonic; languages(isocode); readPrincipals(uid); writePrincipals(uid)
 ; $productCatalog ; $productCatalogVersion;      ; Staged  ; de,en,fr; admin,UserGroupForStagedOnly, UserGroupForStagedAndOnline ; admin,UserGroupForStagedOnly, UserGroupForStagedAndOnline
 ; $productCatalog ; $productCatalogVersionOnline ; TRUE ; Online ; de,en,fr ; admin,UserGroupForStagedAndOnline ; admin, UserGroupForStagedAndOnline
 


former_member625836
Active Contributor
0 Likes

Would also. I don't know the details of requirement. If restricting access to particular catalog versions is enough, then there is no problem with automatic selection on application load 🙂

Cheers, Jacek

pratik_a_soni
Participant
0 Likes

User should have access to other catalog as well to see how the data looks like. But by default it should load with Staged catalog.