3

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

Jatin Gadhiya
  • 1,955
  • 5
  • 23
  • 42
  • check your routing in routeprovider.cs – Curiousdev Mar 14 '17 at 13:52
  • In this file May I know which route ? – Jatin Gadhiya Mar 14 '17 at 14:28
  • for language there is only one route //change language (AJAX link) routes.MapLocalizedRoute("ChangeLanguage", "changelanguage/{langid}", new { controller = "Common", action = "SetLanguage" }, new { langid = @"\d+" }, new[] { "Nop.Web.Controllers" }); – Jatin Gadhiya Mar 16 '17 at 07:49
  • Ohh yes that one please note that there is `\d` regex in `langid` it could be problematic because this means only digits allow in `langid` remove this regex validation or modify it accordingly – Curiousdev Mar 16 '17 at 08:27
  • Yeah. But can you please suggest what need to change in route. I want like this e.g if Vietnam English then url will be /vn-en and if Vietnam Vietnamese then url will be /vn-vi – Jatin Gadhiya Mar 16 '17 at 08:29
  • your route should be something like this `routes.MapLocalizedRoute("ChangeLanguage", "changelanguage/{langid}", new { controller = "Common", action = "SetLanguage" }, null , new[] { "Nop.Web.Controllers" });` – Curiousdev Mar 16 '17 at 08:34
  • I did change still same http://localhost:15536/vn-vi/vn-vi/ and – Jatin Gadhiya Mar 16 '17 at 08:49
  • 1
    @JatinGadhiya: I think to generate it from our side, we need Language pack. can you please provide it. then we can digging with the issue. – Divyang Desai Mar 16 '17 at 11:30
  • I don't have any language pack.. may i know the process for same? I have all resource string for vn-en.. then i will add for vn-vi also... its not right way ? or some language pack available it will load vn-vi resource string automatically ? – Jatin Gadhiya Mar 16 '17 at 12:27

1 Answers1

2

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!

Divyang Desai
  • 7,483
  • 13
  • 50
  • 76