A while back, we had this question on World. It’s not uncommon to update the catalog data by an external system, mostly from a PIM – Product information management system. In such cases, it might not make senses to enable editing in Catalog UI. You might need the new UI for the other parts, such as Marketing UI, but you wouldn’t want the editors to accidentally update the product information – because those would be lost, anyway.
Is there away to do it? Yes, there is.
Catalog UI is built around the content provider concept.
CatalogContentProvider is the provider for catalog content, and it has distinct features compared to the default content provider. Having no waste basket, for example, is one of them. By overriding the “provider capacity”,
CatalogContentProvider tells the content provider system that “Hey, I don’t have, and don’t want to support, waste basket concept”. And the content provider system respects that by hiding the waste basket (“Move to waste basket” command from the context menu is hidden explicitly in Catalog UI code). Can we use that for our cause? Luckily, yes.
What we need to do is to just add this to our site (we are using Quicksilver here)
public class ReadonlyCatalogContentProvider : CatalogContentProvider
public override ContentProviderCapabilities ProviderCapabilities => ContentProviderCapabilities.MultiLanguage;
And then override the default implementation with our own in
Build it, and the magic happens, All properties is now read-only
And the menu commands are disabled:
Yay! But are we done? Not yet. There are parts of Catalog UI which are still editable, naming the relations/associations, the prices and inventories:
The reason was those parts are not handled by the content provider system – so
CatalogContentProvider does not even know about them.
Can we remove/change those parts, to make the UI truly “readonly”. Yes, we can, but it will not be easy or beautiful as above. We will come back to this in the part 2 of this blog post.