This seems to be more of a CMS issue than a Commerce issue. What kind of URL rewriter do you have enabled? And how do you create the link? If you try to do the same thing in edit mode, do you still get the same kind of behavior? Also, what version of Commerce are you using?
I've got a support query going through at the moment which includes logs and sample code etc. I'll update this post as soon as we get to the bottom of it. Yes it seems like a CMS issue, accept the same code works fine in CMS instances as i've used it for many years. Using Commerce 1.0 R2, its a configuration nightmare so i'm wondering if there is something hidden away in the depths of it. As the documentation is pretty poor, its hard to get to the bottom of.
Support didn't really get to the bottom of it - but the following code seems to work:
UrlBuilder internalurl = new UrlBuilder(pageData.LinkURL);
EPiServer.Global.UrlRewriteProvider.ConvertToExternal(internalurl, null, System.Text.Encoding.UTF8);
internalurl.ToString() + "?ec=5468";
if you add the 'ec' parameter at any other point, you don't get the friendly url and then something strips out the 'id' parameter.
Is anyone aware of any Url rewriting that could be taking place within the Commerce Framework that would be removing the ID parameters from PageData.LinkURL?
To create a link to a product page I have to use the LinkURL property of the page I want to go to, then I append the Commerce Catalog Entry Code property, eg. "ec=1234"
When I add this to the value returned by LinkURL and ouput to the link on the page, once the page is fully rendered something has completely stripped out the id parameter and i'm left with the following:
This will then break the PageType (using PageTypeBuilder) as no id is specified. if you manually add the id to the url just so the page works, it still gets stripped out again on any kind of postback.
Any help would be great - also, would be good if some people from EPiServer started having a bit more involvement in the Commerce forum posts - the documentation for development on this new platform is pretty thin lets face it.