How to add the missing vendors search engine friendly page names during nopCommerce installation

Recently, it was reported by nopCommerce users that vendors search engine friendly page names are missing during the installation process. Due to the missing information, a user cannot go to the vendor page if vendor has not been added manually from the administration section (if sample data is being used).

Today, we will go over the process of adding the missing vendors search engine friendly page names during nopCommerce installation.

Go to: ../Libraries/Nop.Services/Installation/CodeFirstInstallationService.cs

 

Open the file “CodeFirstInstallationService.cs” and look for the following method:

protected virtual void InstallVendors()

 

Here is the full method “InstallVendors()”:

protected virtual void InstallVendors()
       {
           var vendors = new List<Vendor>
           {
               new Vendor
               {
                   Name = "Vendor 1",
                   Email = "vendor1email@gmail.com",
                   Description = "Some description...",
                   AdminComment = "",
                   PictureId = 0,
                   Active = true,
                   DisplayOrder = 1,
                   PageSize = 6,
                   AllowCustomersToSelectPageSize = true,
                   PageSizeOptions = "6, 3, 9, 18",
               },
               new Vendor
               {
                   Name = "Vendor 2",
                   Email = "vendor2email@gmail.com",
                   Description = "Some description...",
                   AdminComment = "",
                   PictureId = 0,
                   Active = true,
                   DisplayOrder = 2,
                   PageSize = 6,
                   AllowCustomersToSelectPageSize = true,
                   PageSizeOptions = "6, 3, 9, 18",
               }
           };
 
           _vendorRepository.Insert(vendors);
       }

 

Just like other information in the sample data, vendors search engine friendly page names are missing. In order to add that information, we will update the code like this:

protected virtual void InstallVendors()
       {
           var vendors = new List<Vendor>
           {
               new Vendor
               {
                   Name = "Vendor 1",
                   Email = "vendor1email@gmail.com",
                   Description = "Some description...",
                   AdminComment = "",
                   PictureId = 0,
                   Active = true,
                   DisplayOrder = 1,
                   PageSize = 6,
                   AllowCustomersToSelectPageSize = true,
                   PageSizeOptions = "6, 3, 9, 18",
               },
               new Vendor
               {
                   Name = "Vendor 2",
                   Email = "vendor2email@gmail.com",
                   Description = "Some description...",
                   AdminComment = "",
                   PictureId = 0,
                   Active = true,
                   DisplayOrder = 2,
                   PageSize = 6,
                   AllowCustomersToSelectPageSize = true,
                   PageSizeOptions = "6, 3, 9, 18",
               }
           };
 
           _vendorRepository.Insert(vendors);
 
           //search engine names
            foreach (var vendor in vendors)
            {
                _urlRecordRepository.Insert(new UrlRecord
                {
                    EntityId = vendor.Id,
                    EntityName = "Vendor",
                    LanguageId = 0,
                    IsActive = true,
                    Slug = vendor.ValidateSeName("", vendor.Name, true)
                });
            }
       }

 

Now, let’s open the “create_sample_data.sql” file in this location:
/Presentation/Nop.Web/App_Data/Install/create_sample_data.sql

Add these 2 sql commands for inserting the values:

INSERT [dbo].[UrlRecord] ([Id], [EntityId], [EntityName], [Slug], [IsActive], [LanguageId]) VALUES (81, 1, N'Vendor', N'vendor-1', 1, 0)
INSERT [dbo].[UrlRecord] ([Id], [EntityId], [EntityName], [Slug], [IsActive], [LanguageId]) VALUES (82, 2, N'Vendor', N'vendor-2', 1, 0)

 

Your SQL commands should look like this:

INSERT [dbo].[UrlRecord] ([Id], [EntityId], [EntityName], [Slug], [IsActive], [LanguageId]) VALUES (77, 2, N'BlogPost', N'why-your-online-store-needs-a-wish-list', 1, 1)
INSERT [dbo].[UrlRecord] ([Id], [EntityId], [EntityName], [Slug], [IsActive], [LanguageId]) VALUES (78, 1, N'NewsItem', N'about-nopcommerce', 1, 1)
INSERT [dbo].[UrlRecord] ([Id], [EntityId], [EntityName], [Slug], [IsActive], [LanguageId]) VALUES (79, 2, N'NewsItem', N'nopcommerce-new-release', 1, 1)
INSERT [dbo].[UrlRecord] ([Id], [EntityId], [EntityName], [Slug], [IsActive], [LanguageId]) VALUES (80, 3, N'NewsItem', N'new-online-store-is-open', 1, 1)
INSERT [dbo].[UrlRecord] ([Id], [EntityId], [EntityName], [Slug], [IsActive], [LanguageId]) VALUES (81, 1, N'Vendor', N'vendor-1', 1, 0)
INSERT [dbo].[UrlRecord] ([Id], [EntityId], [EntityName], [Slug], [IsActive], [LanguageId]) VALUES (82, 2, N'Vendor', N'vendor-2', 1, 0)
SET IDENTITY_INSERT [dbo].[UrlRecord] OFF
GO

 

That’s all – Now, if you perform a fresh install of nopCommerce, vendors search engine friendly page names will be added during nopCommerce installation.

 

 Looking for quality nopCommerce Web Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , | Posted under nopCommerce | RSS 2.0

Author Spotlight

Lavish Kumar

Founder, developer and owner of StrivingProgrammers.com - By profession, he is a software programmer / web developer, web designer & DBA. He is passionate about technology and electronic gadgets. He enjoys writing tech articles and developing web applications. He is a nopCommerce MVP and author of official nopCommerce Designer's Guide.

Leave a Reply

Your email address will not be published. Required fields are marked *