Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Davor Zlotrg 6 posts 96 karma points
    Jun 22, 2014 @ 22:04
    Davor Zlotrg
    0

    GetNiceUrlForProduct - multiple language domains problem

    Hi ucommerce,

    I have a catalog that is bound to the "Default" host name and in the content section I have 2 root nodes that represent 2 languages.

    1. mydoamin.com - that is the danish language version hostname
    2. mydomain.com/en/ - that is the english version hostname

    When I am on an english domain and when I call GetNiceUrlForProduct it does not respect the hostname, it returns the product as mydomain.com/product-url instead of mydomain.com/en/product-url?

  • Davor Zlotrg 6 posts 96 karma points
    Jun 23, 2014 @ 13:20
    Davor Zlotrg
    100

    I managed to fix the problem by writing extension method for this.

        public static string GetNiceUrl(this Product product, Category category = null)
        {
            return (GetCurrentDomain() + CatalogLibrary.GetNiceUrlForProduct(product, category));
        }
    
        private static string GetCurrentDomain()
        {
            var domains = Domain.GetDomainsById(uQuery.GetCurrentNode().Id).OrderByDescending(d => d.Name.Length);
            foreach (var domain in domains)
            {
                if(HttpContext.Current.Request.Url.AbsoluteUri.ToLower().Contains(domain.Name.ToLower()))
                {
                    return domain.Name;
                }
            }
            return string.Empty;
        }
    

    Is there maybe a better way to handle this scenario?

Please Sign in or register to post replies

Write your reply to:

Draft