Displaying Unique SEO Code Two Times In The URL When Change Length 2 To 5

My editor is vs2015 community.

Currently default nopCommerce supporting only two character for Unique SEO code

But I need to at least five character. e.g if Vietnam English then url will be /vn-en and if Vietnam Vietnamese then url will be /vn-vi

So I am thinking to add vn-en and vn-vi in Unique SEO code. But its supporting only two character. So i did some change in code.

  1. LanguageMap.cs HasMaxLength(2) to HasMaxLength(5)
  2. LanguageValidator.cs Length(2) to Length(5)
  3. nvarchar(2) to nvarchar(5) in Language table

Then nop is allowing me to add five character in that field.

But when i am changing language from front store then url displaying like /vn-vi/vn-vi. Means displaying seo code two times. And I can see 404 page not found direct html code in output.

When two character in that field then working fine. I have missing some steps?

Anyone can please guide me?

Awaiting for your response



After investigating the issue that you're facing is because of AddLanguageSeoCodeToRawUrl method of LocalizedUrlExtenstions adding SEO code two times.

I think we can make it fix to check UniqueSeoCode before adding it to the URL.

if (!url.Contains(language.UniqueSeoCode))
    //add SEO code
    url = url.Insert(startIndex, language.UniqueSeoCode);
    url = url.Insert(startIndex, "/");

Add if condition in AddLanguageSeoCodeToRawUrl method, and check!

Change _seoCodeLength from 2 to 5 in LocalizedUrlExtenstions at Nop.Web.Framework > Localization

Hope this helps!