When an editor publishes changes while using the All properties view in EPiServer commerce, they're automatically switched to the On-page editing, causing a server error to be displayed.
Setting the default view seems to work just fine for EPiServer CMS but not Commerce. Is there any way I can disable this automatic switching between views on EPiServer commerce?
I tried disabling the on-page edit view, but that causes another issue: when publishing the page, the page never displays that it was published successfully. If I refresh the page, then it does appear that the page is published with the latest changes.
I found the same issue here, but it wasn't solved yet: https://world.episerver.com/forum/developer-forum/Episerver-Commerce/Thread-Container/2019/8/disable-automatic-switch-to-on-page-editing-when-publishing-in-episerver-commerce-/
I figured out what was causing the error. We found that our CategoryController was taking CatalogContentBase as its type parameter (instead of Category), and the BaseVariationContent inherits from that type so the controller was attempting to render a view for the BaseVariationContent type in the previews. We changed the type parameter and now there is no attempt to render views for variants.
Understanding that this thread is pretty old, I wanted to throw this in here in case other folks arrive here with the same question:
Check out the blog post for full details, but:
The default view you want to see, as well as the publish view (i.e. the view after a content is published) can be defined in an UIDescriptor, like this:
public class FashionProductUIDescriptor : UIDescriptor<FashionProduct>
DefaultView = CmsViewNames.AllPropertiesView;
PublishView = CmsViewNames.AllPropertiesView;
With this UIDescriptor, whenever you open a content of type FashionProduct, the default view will be All Properties. And if you make changes and publish, it will stay in that mode.
And note: you would have to define an UIDescriptor for each and every of your strongly typed content type. You can't define an UIDescriptor on ProductContent or EntryContentBase as there are already framework UIDescriptor(s) for them, and having two UIDescriptors with same TypeIdentifier will break your site.