API
Version 7.x > API > Get DocumentURL from SKU View modes: 
User avatar
Certified Developer v7
Certified  Developer v7
ianwright - 11/7/2013 5:57:59 AM
   
Get DocumentURL from SKU
I've currently customizing a basket slightly, I've got a list of SKUInfos from the ShoppingCart.ContentTable. What I want to do is provide a URL back to the original product but I can't seem to make the link from the SKUInfo back to the Product document.

How can I go about grabbing the URL so I can go back to the product page?

Thanks

User avatar
Kentico Consulting
Kentico Consulting
Kentico_RichardS - 11/7/2013 6:27:42 AM
   
RE:Get DocumentURL from SKU
Hi Ian,

Thank you for your message.

I've been dealing with SKU's and their document types. Apart from the limitation of having this in multiple cultures there is yet not a relationshipt between them.

However if you only need to get the URL to the product page you can use the SkuID. I manged to get the link with url in the following way:


string productUrl = "<a href=\"" + ResolveUrl("~/CMSPages/GetProduct.aspx") + "?productid=" + myProduct.SKUID + "\">"+myProduct.SKUName+"</a>";


Given that the myProduct is the SKUInfo object which you currently have.

Let me know how it works.

Kind regards,
Richard Sustek




User avatar
Certified Developer v7
Certified  Developer v7
ianwright - 11/7/2013 6:31:05 AM
   
RE:Get DocumentURL from SKU
Thanks Sustek,

I've just discovered that the EcommerceFunctions.GetProductURL() products the same URL. Now I thought that wouldn't work because that doesn't at all point to the document I want, however I've since discovered that it automatically redirects which wasn't documented in the API, so instead the following is what I needed:

<%# EcommerceFunctions.GetProductURL( Convert.ToInt32(Eval("SKUID"))) %>

User avatar
Kentico Consulting
Kentico Consulting
Kentico_RichardS - 11/7/2013 7:51:56 AM
   
RE:Get DocumentURL from SKU
Hi,

You're welcome.

I"m glad you were able to find a suitable solution and also thank you for sharing with others.

Let us know if you need anything else.

Kind regards,
Richard Sustek