Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

PageEditing.GetEditUrlForLanguage returns edit link to CMS

Vote:
 

Hi,

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

https://localhost:44377/EPiServer/Commerce/Catalog?language=de#context=epi.cms.contentdata:///65__CatalogContent&viewsetting=viewlanguage:///de
it returns something like
https://localhost:44377/EPiServer/CMS//?language=de#context=epi.cms.contentdata:///-2147483640__CatalogContent

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

Regards,

Zsolt

#319187
Mar 19, 2024 11:04
Vote:
 

Hi 

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.


Thanks

#319198
Edited, Mar 19, 2024 14:47
Vote:
 

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

#319199
Mar 19, 2024 15:15
Vote:
 

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.

#319200
Edited, Mar 19, 2024 17:23
Vote:
 

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.

Zsolti

#319242
Mar 20, 2024 8:28
Paul McGann (Netcel) - Mar 20, 2024 9:15
Nice one glad you got it sorted.
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.