I have a subcategory page but on this page if I do the following code which work on anypage, on the subcategory page it return an empty string. Do you have a solution for it? var prd = UCommerce.EntitiesV2.Product.Get(118); var url = UCommerce.Api.CatalogLibrary.GetNiceUrlForProduct(prd3);
Ok finally found the cause of the error. In fact, SiteContext.Current.CatalogContext.CurrentCatalog was not set correctly because my subcategory url rewriting was not correct.
Product url
Hello,
I have a subcategory page but on this page if I do the following code which work on anypage, on the subcategory page it return an empty string. Do you have a solution for it?
var prd = UCommerce.EntitiesV2.Product.Get(118);
var url = UCommerce.Api.CatalogLibrary.GetNiceUrlForProduct(prd3);
Regards,
Benjamin
You save a variable "prd" but insert "prd3" into the GetNiceUrlForProduct() method.
Just a quick guess :)
No sorry it was just the code sample here. Correct code is:
var prd = UCommerce.EntitiesV2.Product.Get(118);
var url = UCommerce.Api.CatalogLibrary.GetNiceUrlForProduct(prd);
It just caught my eye :)
You can try passing the category and catalog into the GetNiceUrlForProduct() aswell.
It is optional parameters, but I think it will fix your issue.
Ok finally found the cause of the error. In fact, SiteContext.Current.CatalogContext.CurrentCatalog was not set correctly because my subcategory url rewriting was not correct.
Thank you for your help,
Benjamin
No problem, glad I could help :)
If you could mark the thread as solved, that would be fantastic :)
is working on a reply...