cancel
Showing results for 
Search instead for 
Did you mean: 

How to disable synchronization button for online catalog products

pavan-yvs-1
Explorer
0 Kudos
122

Hi,

I am trying to disable synchronization button for online products.

What I tried:

I tried a custom Action

{
    Object data = ctx.getData();
    if (data instanceof ProductModel) {
      ProductModel product = (ProductModel) data;
      CatalogVersionModel catalogVersion = product.getCatalogVersion();

      // Disable sync for products in Online catalog version
      if (catalogVersion != null && "Online".equalsIgnoreCase(catalogVersion.getVersion())) {
        return false; // Disable action for Online products
      }
    }
    return super.canPerform(ctx);
  }

 

I tried custom renderer

 

public class CustomSyncActionRenderer implements CockpitActionRenderer {

  @Override
  public void render(Component component, CockpitAction cockpitAction, ActionContext actionContext,
      boolean b, ActionListener actionListener) {
    Object data = actionContext.getData();
    boolean isOnline = false;
    if (data instanceof ProductModel) {
      ProductModel item = (ProductModel) data;
      CatalogVersionModel catalogVersion = item.getCatalogVersion();
      isOnline = catalogVersion != null && "Online".equals(catalogVersion.getVersion());
    }

    Button button = new Button("Synchronize");
    button.setParent(component);
    button.setDisabled(isOnline || !cockpitAction.canPerform(actionContext));
    if (isOnline) {
      button.setTooltiptext("Please sync from Staged product");
    } else {
      button.addEventListener("onClick", event -> cockpitAction.perform(actionContext));
    }
  }
}

 

But no luck.

I appreciate any guidance/help. Thanks in advance!

View Entire Topic
samuelyang
Product and Topic Expert
Product and Topic Expert
0 Kudos

HI @pavan-yvs-1 

Not sure if you're aware, but you can disable synchronization through permission settings in the Backoffice. 

So if you remove or revoke the synchronization permission from the users or user group, the synchronization button would not be available for them. 

samuelyang_1-1745898378108.png

samuelyang_0-1745898289818.png

To revoke or remove the permission, you can cross out or even drop the Synchronization permission entry.

samuelyang_2-1745898797280.png

And BTW, to check for online catalog versions, you can check the active property of the catalog version model, the version property might be changed to something else other than "Online".

catalogVersion.getActive()

Hope that helps 🙂