It has been a while since I write something in my blog – have been “fairly” busy making Commerce even faster for a while. But I should take a break from time to time and share things that will benefit community as a whole – and this is one of that break.
Today I come across this question on World https://world.episerver.com/forum/developer-forum/Episerver-Commerce/Thread-Container/2019/10/remove-item-from-tab-in-content-editor/ . Basically, how to hide a specific tab in the Catalog UI when you open All Properties view of a catalog content.
The original poster has found a solution from https://world.episerver.com/forum/legacy-forums/Episerver-7-CMS/Thread-Container/2013/10/Is-there-any-way-to-hide-the-settings-tab/ . While it works, I think it is not the easiest or simple way to do it. Is there a simpler way? Yes.
The Related Entries tab is generated for content with implements IAssociating
interface. Bad news is EntryContentBase
implements that interface, so each and every entry type you have, has that tab. But good news is we can override the implementation – by just override the property defined by IAssociating
.
How?
Simple as this
/// <inheritdoc />
[IgnoreMetaDataPlusSynchronization]
[Display(AutoGenerateField = false)]
public override Associations Associations { get; set; }
We are overriding the Associations
property, and the change the Display
attribute to have AutoGenerateField = false
. Just try to build it and see
No Related Views! But is it the end of the story. Not yet, Related Views can still be accessed by the menu
A complete solution is to also disable that view. How? By using the same technique here https://world.episerver.com/blogs/Quan-Mai/Dates/2019/8/enable-sticky-mode-for-catalog-content/ i.e. using `UIDescriptor`. You can disable certain views by adding this to your constructor
AddDisabledView(CommerceViewConfiguration.RelatedEntriesEditViewName);
A few notes:
- This only affects the type you add the property, so for example you can hide the tab for Products, but still show it for Variants.
- Related Entries is not the only tab you can hide. By applying the same technique you can have a lot of control over what you can hide, and what you show. I will leave that to you for exploration!
Great write up Quan.
I wonder – is it also possible to also remove ‘higher level’ menus and therefore features like the “Marketing” tab too?
In omnichannel scenarios promotions can often be managed elsewhere (in an ERP system for example) and synchronised with Episerver using the API. These should then not be managed in the Commerce platform.
Hi Marcus, unfortunately there currently isn’t a way to hide those menus. However that is a valid feafure request. I will look into that.
I was trying to use this to hide the Pricing tab, but with no luck. Is it possible to hide this tab?
You should be able to use the same technique with CommerceViewConfiguration.PricingViewName