URL Rewriting

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 years ago
I would like to change the url format to display the manufacturer, product name and part number. I am using the "Short Description" as the manufacturer name, so url format would need to be as follows.

ShortDescription-ProductName-PartNumber.aspx

Just wondering how to achieve this through the nop settings and urlrewriting.config (As well as anything else that is required)

thanks in advance
13 years ago
Just replace NopSolutions.NopCommerce.BusinessLogic.SEO.GetProductUrl(Product product) method with the following one:
public static string GetProductUrl(Product product)
        {
            if (product == null)
                throw new ArgumentNullException("product");
            string seName = GetSEName(product.SEName);
            if (String.IsNullOrEmpty(seName))
            {
                if (product.ProductVariants.Count > 0)
                {
                    seName = GetSEName(product.ShortDescription + "-" + product.Name + "-" + product.ProductVariants[0].ManufacturerPartNumber);
                }
                else
                {
                    seName = GetSEName(product.Name);
                }
            }
            string url2 = SEOHelper.EnableUrlRewriting ? SettingManager.GetSettingValue("SEO.Product.UrlRewriteFormat") : "{0}Product.aspx?ProductID={1}";
            string url = string.Format(url2, CommonHelper.GetStoreLocation(), product.ProductId, seName);
            return url.ToLowerInvariant();
        }

Don't forget to recompile your solution

P.S. Not tested
13 years ago
that works great, thanks heaps. Just replaced this section of the code though.

    if (product.ProductVariants.Count > 0)
                {
                    seName = GetSEName(product.ShortDescription + "-" + product.Name + "-" + product.ProductVariants[0].ManufacturerPartNumber);
                }
                else
                {
                    seName = GetSEName(product.Name);
                }
13 years ago
What about

ShortDescription/ProductName-PartNumber-ID.aspx

ID being the numerical reference thats normally at the start of the URL.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.