How to make your store SEO friendly with nopCommerce Version 2.6? few hints.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 years ago
For making your site more seo friendly:

this topic covers

1) How to Rewrite your page url
2) How to extend the content length of MetaKeyword and Title

here i am explaining only for product. you can use it for Category, manufacturer and etc.

1) How to Rewrite your page url

in nopcommerce normal route for product  you can find it in nop.web/infrastructrue/routeprovider.cs

 routes.MapLocalizedRoute("Product",
                         "p/{productId}/{SeName}",
                          new { controller = "Catalog", action = "Product", SeName = UrlParameter.Optional },
                          new { productId = @"\d+" },
                          new[] { "Nop.Web.Controllers" });


it'll deliver the url as : http://www.yourstore.com/p/1/product-name

but for SEO friendly we change this format to http://www.yourstore.com/product-name/p/1

so we need to change the route to

routes.MapLocalizedRoute("Product",
                           "{SeName}/p/{productId}",
                           new { controller = "Catalog", action = "Product", SeName =UrlParameter.Optional },
                           new { productId = @"\d+" },
                           new[] { "Nop.Web.Controllers" });

but this will cause an error in admin page when edit and save product. the preview also wont work.

to make the preview will work fine you need to edit the Edit.cshml page in Nop.Admin/Views/Products/Edit.cshtml.

find the following line

<
input type="submit" value="@T("Admin.Common.Preview")" onclick="javascript:OpenWindow('@Url.RouteUrl("Product", new { productId = Model.Id, SeName = "" })', 800, 600, true); return false;" class="t-button" />


and change the line to

<input type="submit" value="@T("Admin.Common.Preview")" onclick="javascript:OpenWindow('@Url.RouteUrl("Product", new { productId = Model.Id, SeName =Model.SeName.ToLower().Replace(' ','-') })', 800, 600, true); return false;" class="t-button" />


2) How to extend the content length of MetaKeyword and Title

goto database find product table right click and goto design.

MetaKeywords  nvarchar(400)    to  nvarchar(MAX)
    MetaTitle  nvarchar(400)   to  nvarchar(MAX) close and save it.


do the same for category, manufacturer and etc.

then goto Libraries/Nop.data/Mapping/ProductMap.cs

  
  this.Property(p => p.MetaKeywords).HasMaxLength(400);
to
     this.Property(p => p.MetaKeywords).IsMaxLength();
and
     this.Property(p => p.MetaTitle).HasMaxLength(400);
to
     this.Property(p => p.MetaTitle).IsMaxLength();


do this for categorymap and manufacturermap too.
kindly share your views and post your hints and tricks. :)
11 years ago
elaa1979 wrote:


but this will cause an error in admin page when edit and save product. the preview also wont work.

to make the preview will work fine you need to edit the Edit.cshml page in Nop.Admin/Views/Products/Edit.cshtml.

find the following line

<
input type="submit" value="@T("Admin.Common.Preview")" onclick="javascript:OpenWindow('@Url.RouteUrl("Product", new { productId = Model.Id, SeName = "" })', 800, 600, true); return false;" class="t-button" />


and change the line to

<input type="submit" value="@T("Admin.Common.Preview")" onclick="javascript:OpenWindow('@Url.RouteUrl("Product", new { productId = Model.Id, SeName =Model.SeName.ToLower().Replace(' ','-') })', 800, 600, true); return false;" class="t-button" />




There is a problem with this code.

The SeName column in both Category and Product table is nullable.

The Null value causes an error.
11 years ago
you need to modify in Nop.Web.Framework

GetSename method if the sename is null or empty replace the sename with the product name. that will solve your problem.
11 years ago
elaa1979 wrote:
you need to modify in Nop.Web.Framework

GetSename method if the sename is null or empty replace the sename with the product name. that will solve your problem.


This is not my problem.

This is your problem.

You have supplied buggy code. It is your job, given a bug report, to fix it.

Fobbing me off with some vague fix which I am highly dubious of you even trying let alone testing is just not good enough.

Maybe you could start with explaining where exactly in 'Nop.Web.Framework' GetSeName is located because a full search of nop 2.6 doesn't list getSeName as being present in that part of the project?

Thanks

Daveb
11 years ago
hi buddy.. thanks for your correction. i am working on multiple projects. so some time i cant go through the actual code and write the solution. its my fault. execuse me.

instead of using Model.SeName in the code use GetSeName(model) method. this will returns a string. if the sename of the product is null it'll return product name.
this method is located in Libraries/Nop.Services/Seo/SeoExtension.cs file. name space is Nop.Services.Seo;
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.