Try our conversational search powered by Generative AI!

PageEditing.GetEditUrlForLanguage returns edit link to CMS



Using Commerce 13.34.

When generating edit link for a Commerce content with PageEditing.GetEditUrlForLanguage(), it always returns a link to CMS instead of Commerce, so context is invalid, meaning instead of link

it returns something like

Is there a way to generate an edit link correctly in Commerce content? Apparently PageEditing hardcodes "CMS" in implementation.



Mar 19, 2024 11:04


I don't believe the 'PageEditing' will give you what you want however you could try using the urlresovler:

var virtualPathArguments = new VirtualPathArguments { ContextMode = ContextMode.Edit};
var url = ServiceLocator.Current.GetInstance<UrlResolver>().GetUrl(currentProduct.ContentLink, "de", virtualPathArguments);

 This is by no means production code though might help point you in the right direction.


Edited, Mar 19, 2024 14:47

Thank you for your answer, I tried this already, this also results a url inside CMS interface, but invalid for my Commerce content.

Mar 19, 2024 15:15

I haven't tried this however this is based upon the PageEditing.GetEditUrlForLanguage.

string.Format("{0}/?language={1}#context=epi.cms.contentdata:///{2}", ModuleResourceResolver.Instance.ResolvePath("Commerce", null).TrimEnd('/'), language, contentLink)

I'll have a play around later and see if I can come up with something solid.

There should be away to do it, as the Optimizely quicknavigation can do it.

Edited, Mar 19, 2024 17:23

My collagaue found EPiServer.Web.Routing.EditUrlResolver.GetEditViewUrl(), which is working great for CMS and Commerce, apparently other variants should not be used.

Thanks for your help.


Mar 20, 2024 8:28
Paul McGann (Netcel) - Mar 20, 2024 9:15
Nice one glad you got it sorted.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.