on 2025 Apr 14 11:16 PM
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!
Request clarification before answering.
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.
To revoke or remove the permission, you can cross out or even drop the Synchronization permission entry.
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 🙂
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.