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. :)