--upgrade scripts from nopCommerce 2.20 to nopCommerce 2.30 --new locale resources declare @resources xml --a resource will be delete if its value is empty set @resources=' ASP.NET info Is full trust level nopCommerce version Operating system Server local time Server time zone Greenwich mean time (GMT/UTC) Configuration is not required Allow customers to check the availability of usernames A value indicating whether customers are allowed to check the availability of usernames (when registering or changing in ''My Account''). Username available Current username Username not available Check Availability The credentials provided are incorrect Billing address info Shipping address info Bill to this address Allow customers to select page size Whether customers are allowed to select the page size from a predefined list of options. Page Size options (comma separated) Comma separated list of page size options (e.g. 10, 5, 15, 20). First option is the default page size if none are selected. Allow customers to select page size Whether customers are allowed to select the page size from a predefined list of options. Page Size options (comma separated) Comma separated list of page size options (e.g. 10, 5, 15, 20). First option is the default page size if none are selected. Allow customers to select ''Products by tag'' page size Whether customers are allowed to select the ''Products by tag'' page size from a predefined list of options. ''Products by tag'' Page Size options (comma separated) Comma separated list of page size options (e.g. 10, 5, 15, 20). First option is the default page size if none are selected. Display per page Display per page Display per page Add a new state/province Edit state/province The new shipping method has been added successfully. The shipping method has been updated successfully. The shipping method has been deleted successfully. back to shipping method list Add a new shipping method Edit shipping method details Special price Set a special price for the product variant. New price will be valid between start and end dates. Leave empty to ignore field. Special price start date The start date of the special price in Coordinated Universal Time (UTC). Special price end date The end date of the special price in Coordinated Universal Time (UTC). Configure Configure back to plugin list Product name A product name. Category Search by a specific category. Manufacturer Search by a specific manufacturer. Use SSL Click if your site is secured with SSL. Don''t tick if SSL certificate is not installed. Shared SSL URL Enter your shared SSL URL (used when you have shared SSL certificate installed). For example, https://secure123.yourHosting.com/. Non-secured URL Enter your non-secured URL (used when you have shared SSL certificate installed). Actually it is your site URL. For example, http://www.example.com/. Allow back in stock subscriptions Allow customers to subscribe to a notification list for a product that has gone out of stock. Hide ''Back in stock subscriptions'' tab Check to hide ''Back in stock subscriptions'' tab on ''My account'' page Back in stock subscriptions Back in stock subscriptions Product Delete selected You are not currently subscribed to any Back In Stock notification lists You will receive an e-mail when a particular product is back in stock. You are not currently subscribed to any forums You''re already subscribed for this product back in stock notification Receive an email when this arrives in stock Subscriptions are not allowed for this product Only registered customers can used this feature You cannot subscribe. Maximum number of allowed subscriptions is {0} You''ll receive a one time e-mail when this product is available for ordering again. We will not send you any other e-mails or add you to our newsletter, you will only be e-mailed about this product! Unsubscribe Notify me Notify me when available Allow an admin to view the closed store Check to allow a user with admin access to view the store while it is set to closed. Date of birth Filter by date of birth. Don''t select any value to load all records. Day Month The password should have at least {0} characters. The password should have at least {0} characters. The password should have at least {0} characters. Hide admin menu items based on permissions Hide admin menu items when access to them is denied according to access control list (permissions). Discount requirement saved Entered coupon code - {0} Out of Stock - on backorder and will be dispatched once in stock. Use Letter page size If checked, uses Letter page size for PDF documents. Uses A4 page size if unchecked. GTIN (global trade item number) Enter global trade item number (GTIN). These identifiers include UPC (in North America), EAN (in Europe), JAN (in Japan), and ISBN (for books). Send test email to ensure that everything is properly configured. New Address Show GTIN Check to show GTIN in public store. GTIN ' CREATE TABLE #LocaleStringResourceTmp ( [ResourceName] [nvarchar](200) NOT NULL, [ResourceValue] [nvarchar](max) NOT NULL ) INSERT INTO #LocaleStringResourceTmp (ResourceName, ResourceValue) SELECT nref.value('@Name', 'nvarchar(200)'), nref.value('Value[1]', 'nvarchar(MAX)') FROM @resources.nodes('//Language/LocaleResource') AS R(nref) --do it for each existing language DECLARE @ExistingLanguageID int DECLARE cur_existinglanguage CURSOR FOR SELECT [ID] FROM [Language] OPEN cur_existinglanguage FETCH NEXT FROM cur_existinglanguage INTO @ExistingLanguageID WHILE @@FETCH_STATUS = 0 BEGIN DECLARE @ResourceName nvarchar(200) DECLARE @ResourceValue nvarchar(MAX) DECLARE cur_localeresource CURSOR FOR SELECT ResourceName, ResourceValue FROM #LocaleStringResourceTmp OPEN cur_localeresource FETCH NEXT FROM cur_localeresource INTO @ResourceName, @ResourceValue WHILE @@FETCH_STATUS = 0 BEGIN IF (EXISTS (SELECT 1 FROM [LocaleStringResource] WHERE LanguageID=@ExistingLanguageID AND ResourceName=@ResourceName)) BEGIN UPDATE [LocaleStringResource] SET [ResourceValue]=@ResourceValue WHERE LanguageID=@ExistingLanguageID AND ResourceName=@ResourceName END ELSE BEGIN INSERT INTO [LocaleStringResource] ( [LanguageID], [ResourceName], [ResourceValue] ) VALUES ( @ExistingLanguageID, @ResourceName, @ResourceValue ) END IF (@ResourceValue is null or @ResourceValue = '') BEGIN DELETE [LocaleStringResource] WHERE LanguageID=@ExistingLanguageID AND ResourceName=@ResourceName END FETCH NEXT FROM cur_localeresource INTO @ResourceName, @ResourceValue END CLOSE cur_localeresource DEALLOCATE cur_localeresource --fetch next language identifier FETCH NEXT FROM cur_existinglanguage INTO @ExistingLanguageID END CLOSE cur_existinglanguage DEALLOCATE cur_existinglanguage DROP TABLE #LocaleStringResourceTmp GO --new setting IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'commonsettings.enablehttpcompression') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'commonsettings.enablehttpcompression', N'true') END GO --customer can't be deleted until it has associated log records IF EXISTS (SELECT 1 FROM sys.objects WHERE name = 'Log_Customer' AND parent_object_id = Object_id('Log') AND Objectproperty(object_id,N'IsForeignKey') = 1) ALTER TABLE dbo.[Log] DROP CONSTRAINT Log_Customer GO ALTER TABLE [dbo].[Log] WITH CHECK ADD CONSTRAINT [Log_Customer] FOREIGN KEY([CustomerId]) REFERENCES [dbo].[Customer] ([Id]) ON DELETE CASCADE GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'catalogsettings.defaultcategorypagesizeoptions') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'catalogsettings.defaultcategorypagesizeoptions', N'4, 2, 8, 12') END GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'catalogsettings.defaultmanufacturerpagesizeoptions') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'catalogsettings.defaultmanufacturerpagesizeoptions', N'4, 2, 8, 12') END GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'catalogsettings.productsbytagallowcustomerstoselectpagesize') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'catalogsettings.productsbytagallowcustomerstoselectpagesize', N'True') END GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'catalogsettings.productsbytagpagesizeoptions') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'catalogsettings.productsbytagpagesizeoptions', N'4, 2, 8, 12') END GO --Add fields to Category IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[dbo].[Category]') and NAME='AllowCustomersToSelectPageSize') BEGIN ALTER TABLE [dbo].[Category] ADD [AllowCustomersToSelectPageSize] bit NULL END GO UPDATE [dbo].[Category] SET [AllowCustomersToSelectPageSize] = 1 WHERE [AllowCustomersToSelectPageSize] IS NULL GO ALTER TABLE [dbo].[Category] ALTER COLUMN [AllowCustomersToSelectPageSize] bit NOT NULL GO IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[dbo].[Category]') and NAME='PageSizeOptions') BEGIN ALTER TABLE [dbo].[Category] ADD [PageSizeOptions] nvarchar(200) NULL END GO UPDATE [dbo].[Category] SET [PageSizeOptions] = N'4, 2, 8, 12' WHERE [PageSizeOptions] IS NULL GO --Add fields to Manufacturer IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[dbo].[Manufacturer]') and NAME='AllowCustomersToSelectPageSize') BEGIN ALTER TABLE [dbo].[Manufacturer] ADD [AllowCustomersToSelectPageSize] bit NULL END GO UPDATE [dbo].[Manufacturer] SET [AllowCustomersToSelectPageSize] = 1 WHERE [AllowCustomersToSelectPageSize] IS NULL GO ALTER TABLE [dbo].[Manufacturer] ALTER COLUMN [AllowCustomersToSelectPageSize] bit NOT NULL GO IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[dbo].[Manufacturer]') and NAME='PageSizeOptions') BEGIN ALTER TABLE [dbo].[Manufacturer] ADD [PageSizeOptions] nvarchar(200) NULL END GO UPDATE [dbo].[Manufacturer] SET [PageSizeOptions] = N'4, 2, 8, 12' WHERE [PageSizeOptions] IS NULL GO --Add special price support IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[dbo].[ProductVariant]') and NAME='SpecialPrice') BEGIN ALTER TABLE [dbo].[ProductVariant] ADD [SpecialPrice] decimal(18, 4) NULL END GO IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[dbo].[ProductVariant]') and NAME='SpecialPriceStartDateTimeUtc') BEGIN ALTER TABLE [dbo].[ProductVariant] ADD [SpecialPriceStartDateTimeUtc] datetime NULL END GO IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[dbo].[ProductVariant]') and NAME='SpecialPriceEndDateTimeUtc') BEGIN ALTER TABLE [dbo].[ProductVariant] ADD [SpecialPriceEndDateTimeUtc] datetime NULL END GO --Update stored procedure according to new special price properties IF EXISTS ( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ProductLoadAllPaged]') AND OBJECTPROPERTY(object_id,N'IsProcedure') = 1) DROP PROCEDURE [dbo].[ProductLoadAllPaged] GO CREATE PROCEDURE [dbo].[ProductLoadAllPaged] ( @CategoryId int = 0, @ManufacturerId int = 0, @ProductTagId int = 0, @FeaturedProducts bit = null, --0 featured only , 1 not featured only, null - load all products @PriceMin decimal(18, 4) = null, @PriceMax decimal(18, 4) = null, @Keywords nvarchar(MAX) = null, @SearchDescriptions bit = 0, @FilteredSpecs nvarchar(300) = null, --filter by attributes (comma-separated list). e.g. 14,15,16 @LanguageId int = 0, @OrderBy int = 0, --0 position, 5 - Name, 10 - Price, 15 - creation date @PageIndex int = 0, @PageSize int = 2147483644, @ShowHidden bit = 0, @TotalRecords int = null OUTPUT ) AS BEGIN --init DECLARE @SearchKeywords bit SET @SearchKeywords = 1 IF (@Keywords IS NULL OR @Keywords = N'') SET @SearchKeywords = 0 SET @Keywords = isnull(@Keywords, '') SET @Keywords = '%' + rtrim(ltrim(@Keywords)) + '%' --filter by attributes SET @FilteredSpecs = isnull(@FilteredSpecs, '') CREATE TABLE #FilteredSpecs ( SpecificationAttributeOptionId int not null ) INSERT INTO #FilteredSpecs (SpecificationAttributeOptionId) SELECT CAST(data as int) FROM dbo.[nop_splitstring_to_table](@FilteredSpecs, ','); DECLARE @SpecAttributesCount int SELECT @SpecAttributesCount = COUNT(1) FROM #FilteredSpecs --paging DECLARE @PageLowerBound int DECLARE @PageUpperBound int DECLARE @RowsToReturn int SET @RowsToReturn = @PageSize * (@PageIndex + 1) SET @PageLowerBound = @PageSize * @PageIndex SET @PageUpperBound = @PageLowerBound + @PageSize + 1 CREATE TABLE #DisplayOrderTmp ( [Id] int IDENTITY (1, 1) NOT NULL, [ProductId] int NOT NULL ) INSERT INTO #DisplayOrderTmp ([ProductId]) SELECT p.Id FROM Product p with (NOLOCK) LEFT OUTER JOIN Product_Category_Mapping pcm with (NOLOCK) ON p.Id=pcm.ProductId LEFT OUTER JOIN Product_Manufacturer_Mapping pmm with (NOLOCK) ON p.Id=pmm.ProductId LEFT OUTER JOIN Product_ProductTag_Mapping pptm with (NOLOCK) ON p.Id=pptm.Product_Id LEFT OUTER JOIN ProductVariant pv with (NOLOCK) ON p.Id = pv.ProductId --searching of the localized values --comment the line below if you don't use it. It'll improve the performance LEFT OUTER JOIN LocalizedProperty lp with (NOLOCK) ON p.Id = lp.EntityId AND lp.LanguageId = @LanguageId AND lp.LocaleKeyGroup = N'Product' WHERE ( ( @CategoryId IS NULL OR @CategoryId=0 OR (pcm.CategoryId=@CategoryId AND (@FeaturedProducts IS NULL OR pcm.IsFeaturedProduct=@FeaturedProducts)) ) AND ( @ManufacturerId IS NULL OR @ManufacturerId=0 OR (pmm.ManufacturerId=@ManufacturerId AND (@FeaturedProducts IS NULL OR pmm.IsFeaturedProduct=@FeaturedProducts)) ) AND ( @ProductTagId IS NULL OR @ProductTagId=0 OR pptm.ProductTag_Id=@ProductTagId ) AND ( @ShowHidden = 1 OR p.Published = 1 ) AND ( p.Deleted=0 ) AND ( @ShowHidden = 1 OR pv.Published = 1 ) AND ( @ShowHidden = 1 OR pv.Deleted = 0 ) AND ( --min price (@PriceMin IS NULL OR @PriceMin=0) OR ( --special price (specified price and valid date range) (pv.SpecialPrice IS NOT NULL AND (getutcdate() BETWEEN isnull(pv.SpecialPriceStartDateTimeUtc, '1/1/1900') AND isnull(pv.SpecialPriceEndDateTimeUtc, '1/1/2999'))) AND (pv.SpecialPrice >= @PriceMin) ) OR ( --regular price (price isn't specified or date range isn't valid) (pv.SpecialPrice IS NULL OR (getutcdate() NOT BETWEEN isnull(pv.SpecialPriceStartDateTimeUtc, '1/1/1900') AND isnull(pv.SpecialPriceEndDateTimeUtc, '1/1/2999'))) AND (pv.Price >= @PriceMin) ) ) AND ( --max price (@PriceMax IS NULL OR @PriceMax=2147483644) -- max value OR ( --special price (specified price and valid date range) (pv.SpecialPrice IS NOT NULL AND (getutcdate() BETWEEN isnull(pv.SpecialPriceStartDateTimeUtc, '1/1/1900') AND isnull(pv.SpecialPriceEndDateTimeUtc, '1/1/2999'))) AND (pv.SpecialPrice <= @PriceMax) ) OR ( --regular price (price isn't specified or date range isn't valid) (pv.SpecialPrice IS NULL OR (getutcdate() NOT BETWEEN isnull(pv.SpecialPriceStartDateTimeUtc, '1/1/1900') AND isnull(pv.SpecialPriceEndDateTimeUtc, '1/1/2999'))) AND (pv.Price <= @PriceMax) ) ) AND ( @SearchKeywords = 0 or ( -- search standard content patindex(@Keywords, p.name) > 0 or patindex(@Keywords, pv.name) > 0 or patindex(@Keywords, pv.sku) > 0 or (@SearchDescriptions = 1 and patindex(@Keywords, p.ShortDescription) > 0) or (@SearchDescriptions = 1 and patindex(@Keywords, p.FullDescription) > 0) or (@SearchDescriptions = 1 and patindex(@Keywords, pv.Description) > 0) --searching of the localized values --comment the lines below if you don't use it. It'll improve the performance or (lp.LocaleKey = N'Name' and patindex(@Keywords, lp.LocaleValue) > 0) or (@SearchDescriptions = 1 and lp.LocaleKey = N'ShortDescription' and patindex(@Keywords, lp.LocaleValue) > 0) or (@SearchDescriptions = 1 and lp.LocaleKey = N'FullDescription' and patindex(@Keywords, lp.LocaleValue) > 0) ) ) AND ( @ShowHidden = 1 OR (getutcdate() between isnull(pv.AvailableStartDateTimeUtc, '1/1/1900') and isnull(pv.AvailableEndDateTimeUtc, '1/1/2999')) ) AND ( --filter by specs @SpecAttributesCount = 0 OR ( NOT EXISTS( SELECT 1 FROM #FilteredSpecs [fs] WHERE [fs].SpecificationAttributeOptionId NOT IN ( SELECT psam.SpecificationAttributeOptionId FROM dbo.Product_SpecificationAttribute_Mapping psam WHERE psam.AllowFiltering = 1 AND psam.ProductId = p.Id ) ) ) ) ) ORDER BY CASE WHEN @OrderBy = 0 AND @CategoryId IS NOT NULL AND @CategoryId > 0 THEN pcm.DisplayOrder END ASC, CASE WHEN @OrderBy = 0 AND @ManufacturerId IS NOT NULL AND @ManufacturerId > 0 THEN pmm.DisplayOrder END ASC, CASE WHEN @OrderBy = 0 THEN p.[Name] END ASC, CASE WHEN @OrderBy = 5 --THEN dbo.[nop_getnotnullnotempty](pl.[Name],p.[Name]) END ASC, THEN p.[Name] END ASC, CASE WHEN @OrderBy = 10 THEN pv.Price END ASC, CASE WHEN @OrderBy = 15 THEN p.CreatedOnUtc END DESC DROP TABLE #FilteredSpecs CREATE TABLE #PageIndex ( [IndexId] int IDENTITY (1, 1) NOT NULL, [ProductId] int NOT NULL ) INSERT INTO #PageIndex ([ProductId]) SELECT ProductId FROM #DisplayOrderTmp with (NOLOCK) GROUP BY ProductId ORDER BY min([Id]) --total records SET @TotalRecords = @@rowcount SET ROWCOUNT @RowsToReturn DROP TABLE #DisplayOrderTmp --return products (returned properties should be synchronized with 'Product' entity) SELECT p.Id, p.Name, p.ShortDescription, p.FullDescription, p.AdminComment, p.ProductTemplateId, p.ShowOnHomePage, p.MetaKeywords, p.MetaDescription, p.MetaTitle, p.SeName, p.AllowCustomerReviews, p.ApprovedRatingSum, p.NotApprovedRatingSum, p.ApprovedTotalReviews, p.NotApprovedTotalReviews, p.Published, p.Deleted, p.CreatedOnUtc, p.UpdatedOnUtc FROM #PageIndex [pi] INNER JOIN Product p with (NOLOCK) on p.Id = [pi].[ProductId] WHERE [pi].IndexId > @PageLowerBound AND [pi].IndexId < @PageUpperBound ORDER BY IndexId SET ROWCOUNT 0 DROP TABLE #PageIndex END GO --scheduled tasks are stored into database now IF NOT EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ScheduleTask]') and OBJECTPROPERTY(object_id, N'IsUserTable') = 1) BEGIN CREATE TABLE [dbo].[ScheduleTask]( [Id] [int] IDENTITY(1,1) NOT NULL, [Name] [nvarchar](MAX) NOT NULL, [Seconds] [int] NOT NULL, [Type] [nvarchar](MAX) NOT NULL, [Enabled] [bit] NOT NULL, [StopOnError] [bit] NOT NULL, PRIMARY KEY CLUSTERED ( [Id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ) END GO IF NOT EXISTS ( SELECT 1 FROM [dbo].[ScheduleTask] WHERE [Name] = N'Send emails') BEGIN INSERT [dbo].[ScheduleTask] ([Name], [Seconds], [Type], [Enabled], [StopOnError]) VALUES (N'Send emails', 60, N'Nop.Services.Messages.QueuedMessagesSendTask, Nop.Services', 1, 0) END GO IF NOT EXISTS ( SELECT 1 FROM [dbo].[ScheduleTask] WHERE [Name] = N'Delete guests') BEGIN INSERT [dbo].[ScheduleTask] ([Name], [Seconds], [Type], [Enabled], [StopOnError]) VALUES (N'Delete guests', 600, N'Nop.Services.Customers.DeleteGuestsTask, Nop.Services', 1, 0) END GO IF NOT EXISTS ( SELECT 1 FROM [dbo].[ScheduleTask] WHERE [Name] = N'Clear cache') BEGIN INSERT [dbo].[ScheduleTask] ([Name], [Seconds], [Type], [Enabled], [StopOnError]) VALUES (N'Clear cache', 600, N'Nop.Services.Caching.ClearCacheTask, Nop.Services', 0, 0) END GO IF NOT EXISTS ( SELECT 1 FROM [dbo].[ScheduleTask] WHERE [Name] = N'Update currency exchange rates') BEGIN INSERT [dbo].[ScheduleTask] ([Name], [Seconds], [Type], [Enabled], [StopOnError]) VALUES (N'Update currency exchange rates', 900, N'Nop.Services.Directory.UpdateExchangeRateTask, Nop.Services', 1, 0) END GO --back in stock notification subscriptions IF NOT EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[BackInStockSubscription]') and OBJECTPROPERTY(object_id, N'IsUserTable') = 1) BEGIN CREATE TABLE [dbo].[BackInStockSubscription]( [Id] [int] IDENTITY(1,1) NOT NULL, [ProductVariantId] [int] NOT NULL, [CustomerId] [int] NOT NULL, [CreatedOnUtc] [datetime] NOT NULL, PRIMARY KEY CLUSTERED ( [Id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ) END GO IF EXISTS (SELECT 1 FROM sys.objects WHERE name = 'BackInStockSubscription_ProductVariant' AND parent_object_id = Object_id('BackInStockSubscription') AND Objectproperty(object_id,N'IsForeignKey') = 1) ALTER TABLE dbo.BackInStockSubscription DROP CONSTRAINT BackInStockSubscription_ProductVariant GO ALTER TABLE [dbo].[BackInStockSubscription] WITH CHECK ADD CONSTRAINT [BackInStockSubscription_ProductVariant] FOREIGN KEY([ProductVariantId]) REFERENCES [dbo].[ProductVariant] ([Id]) ON DELETE CASCADE GO IF EXISTS (SELECT 1 FROM sys.objects WHERE name = 'BackInStockSubscription_Customer' AND parent_object_id = Object_id('BackInStockSubscription') AND Objectproperty(object_id,N'IsForeignKey') = 1) ALTER TABLE dbo.BackInStockSubscription DROP CONSTRAINT BackInStockSubscription_Customer GO ALTER TABLE [dbo].[BackInStockSubscription] WITH CHECK ADD CONSTRAINT [BackInStockSubscription_Customer] FOREIGN KEY([CustomerId]) REFERENCES [dbo].[Customer] ([Id]) ON DELETE CASCADE GO IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[dbo].[ProductVariant]') and NAME='AllowBackInStockSubscriptions') BEGIN ALTER TABLE [dbo].[ProductVariant] ADD [AllowBackInStockSubscriptions] bit NULL END GO UPDATE [dbo].[ProductVariant] SET [AllowBackInStockSubscriptions] = 0 WHERE [AllowBackInStockSubscriptions] IS NULL GO ALTER TABLE [dbo].[ProductVariant] ALTER COLUMN [AllowBackInStockSubscriptions] bit NOT NULL GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'customersettings.hidebackinstocksubscriptionstab') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'customersettings.hidebackinstocksubscriptionstab', N'false') END GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'catalogsettings.maximumbackinstocksubscriptions') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'catalogsettings.maximumbackinstocksubscriptions', N'200') END GO IF NOT EXISTS ( SELECT 1 FROM [dbo].[MessageTemplate] WHERE [Name] = N'Customer.BackInStock') BEGIN INSERT [dbo].[MessageTemplate] ([Name], [BccEmailAddresses], [Subject], [Body], [IsActive], [EmailAccountId]) VALUES (N'Customer.BackInStock', null, N'%Store.Name%. Back in stock notification', N'

%Store.Name%

Hello %Customer.FullName%,
Product "%BackInStockSubscription.ProductName%" is in stock.

', 1, 0) END GO --permissions UPDATE [PermissionRecord] SET [Name] = N'Admin area. ' + [Name] WHERE [Name] like N'Manage%' GO UPDATE [PermissionRecord] SET [Name] = N'Plugins. Access Web Service' WHERE [Name] = N'Access Web Service' GO --new 'permission records IF NOT EXISTS ( SELECT 1 FROM [dbo].[PermissionRecord] WHERE [SystemName] = N'DisplayPrices') BEGIN INSERT [dbo].[PermissionRecord] ([Name], [SystemName], [Category]) VALUES (N'Public store. Display Prices', N'DisplayPrices', N'PublicStore') DECLARE @PermissionRecordId INT SET @PermissionRecordId = @@IDENTITY --add it to all roles DECLARE @CustomerRoleId int DECLARE cur_customerrole CURSOR FOR SELECT Id FROM [CustomerRole] OPEN cur_customerrole FETCH NEXT FROM cur_customerrole INTO @CustomerRoleId WHILE @@FETCH_STATUS = 0 BEGIN INSERT [dbo].[PermissionRecord_Role_Mapping] ([PermissionRecord_Id], [CustomerRole_Id]) VALUES (@PermissionRecordId, @CustomerRoleId) FETCH NEXT FROM cur_customerrole INTO @CustomerRoleId END CLOSE cur_customerrole DEALLOCATE cur_customerrole END GO IF NOT EXISTS ( SELECT 1 FROM [dbo].[PermissionRecord] WHERE [SystemName] = N'EnableWishlist') BEGIN INSERT [dbo].[PermissionRecord] ([Name], [SystemName], [Category]) VALUES (N'Public store. Enable wishlist', N'EnableWishlist', N'PublicStore') DECLARE @PermissionRecordId INT SET @PermissionRecordId = @@IDENTITY --add it to all roles DECLARE @CustomerRoleId int DECLARE cur_customerrole CURSOR FOR SELECT Id FROM [CustomerRole] OPEN cur_customerrole FETCH NEXT FROM cur_customerrole INTO @CustomerRoleId WHILE @@FETCH_STATUS = 0 BEGIN INSERT [dbo].[PermissionRecord_Role_Mapping] ([PermissionRecord_Id], [CustomerRole_Id]) VALUES (@PermissionRecordId, @CustomerRoleId) FETCH NEXT FROM cur_customerrole INTO @CustomerRoleId END CLOSE cur_customerrole DEALLOCATE cur_customerrole END GO IF NOT EXISTS ( SELECT 1 FROM [dbo].[PermissionRecord] WHERE [SystemName] = N'EnableShoppingCart') BEGIN INSERT [dbo].[PermissionRecord] ([Name], [SystemName], [Category]) VALUES (N'Public store. Enable shopping cart', N'EnableShoppingCart', N'PublicStore') DECLARE @PermissionRecordId INT SET @PermissionRecordId = @@IDENTITY --add it to all roles DECLARE @CustomerRoleId int DECLARE cur_customerrole CURSOR FOR SELECT Id FROM [CustomerRole] OPEN cur_customerrole FETCH NEXT FROM cur_customerrole INTO @CustomerRoleId WHILE @@FETCH_STATUS = 0 BEGIN INSERT [dbo].[PermissionRecord_Role_Mapping] ([PermissionRecord_Id], [CustomerRole_Id]) VALUES (@PermissionRecordId, @CustomerRoleId) FETCH NEXT FROM cur_customerrole INTO @CustomerRoleId END CLOSE cur_customerrole DEALLOCATE cur_customerrole END GO --min password length IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'customersettings.passwordminlength') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'customersettings.passwordminlength', N'6') END GO --new PayPal setting IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'paypalstandardpaymentsettings.enableipn') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'paypalstandardpaymentsettings.enableipn', N'true') END GO --new setting indicating we should store last visited page URL for each customer IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'customersettings.storelastvisitedpage') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'customersettings.storelastvisitedpage', N'true') END GO --new PDF setting enables PDF documents to use Letter page size if true, else A4 page size IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'pdfsettings.letterpagesizeenabled') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'pdfsettings.letterpagesizeenabled', N'false') END GO --new GTIN property of product variants IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[dbo].[ProductVariant]') and NAME='Gtin') BEGIN ALTER TABLE [dbo].[ProductVariant] ADD [Gtin] nvarchar(400) NULL END GO --new setting IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'ordersettings.onepagecheckoutdisplayordertotalsonpaymentinfotab') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'ordersettings.onepagecheckoutdisplayordertotalsonpaymentinfotab', N'false') END GO --new setting (PDF font path) IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'pdfsettings.fontfilename') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'pdfsettings.fontfilename', N'FreeSerif.ttf') END GO --new setting (display GTIN) IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'catalogsettings.showgtin') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'catalogsettings.showgtin', N'false') END GO