--upgrade scripts from nopCommerce 2.50 to nopCommerce 2.60 --new locale resources declare @resources xml --a resource will be delete if its value is empty set @resources=' Customer Customer Assigned to categories A list of categories to which the discount is to be applied. You can assign this discount on a category details page. No categories selected Assigned to product variants A list of product variants to which the discount is to be applied. You can assign this discount on a product variant details page. No products selected ''{0}'' plugin is incompatible with your nopCommerce version. Delete it or update to the latest version. Start date Set the news item start date or leave empty. End date Set the news item end date or leave empty. Start date Set the blog post start date or leave empty. End date Set the blog post end date or leave empty. Shipments Start date The start date (shipped on) for the search End date The end date (shipped on) for the search. Order # Print packaging slips (all) Print packaging slips (selected) Enter shipping method name. The display order of this shipping method. 1 represents the top of the list. Enter shipping method description. Installing plugin... Uninstalling plugin... Restarting the application... Yes Category name A category name. Manufacturer name A manufacturer name. SKU SKU Show emails Show usernames Show full names Default password format Choose default password format. Please keep in mind that this setting will be applied only to the newly registered customers. Clear Hashed Encrypted Loaded assemblies A list of loaded assemblies Hide Show All directory permissions are OK The ''{0}'' account is not granted with Modify permission on folder ''{1}''. Please configure these permissions. All file permissions are OK The ''{0}'' account is not granted with Modify permission on file ''{1}''. Please configure these permissions. The ''{0}'' account is not granted with Modify permission on file ''{1}''. Please configure these permissions. Show on blog page (comments) Check to show CAPTCHA on blog page when writing a comment. Show on news page (comments) Check to show CAPTCHA on news page when writing a comment. Show on product reviews page Check to show CAPTCHA on product reviews page when writing a review. Not yet Not yet Set as shipped Products in shipment The start date (shipment creation date) for the search The end date (shipment creation date) for the search. Error Notification Warning Terms of service Edit plugin details The friendly name of the plugin. The display order of the plugin. 1 represents the top of the list. Friendly name is required. You cannot vote for your own review Delete (selected) Your cookie settings On 26 May 2011, the rules about cookies on websites changed. This site uses cookies. One or more of the cookies we use is essential for parts of this website to operate and has already been set. You may delete and block all cookies from this site, but parts of the site will not work. To find out more about cookies used on this website and how to delete cookies, see our privacy policy OK Cancel You cannot browse this site until you accept cookies Hide Show Display EU cookie law warning Make the site EU cookie law compliant. When enabled, new customers will see an appropriate warning box. Please provide a name. The name of the product tag. Edit product tag details {0}. Contact us To find text or a specific resource (by name), you can apply a filter via the funnel icon in the "Value" or "Resource name" column headers. To find text or a specific setting (by name), you can apply a filter via the funnel icon in the "Value" or "Setting name" column headers. If an asterisk is selected, then this shipping rate will apply to all customers, regardless of the country. If an asterisk is selected, then this tax rate will apply to all customers from the given country, regardless of the state. Mini-shopping cart product number Specify the maximum number of products which can be displayed in the mini-shopping cart block. Show product images in mini-shopping cart Determines whether product images should be displayed in the mini-shopping cart block. Mini-shopping cart thumbnail image size The default size (pixels) for product thumbnail images in the mini-shopping cart block. Go to cart Quantity Unit price Determines whether product images should be displayed in your store shopping cart. Determines whether product images should be displayed on customer wishlists. Please enter your email address below. You will receive a link to reset your password. Search autocomplete enabled Check to enabled autocomplete in the search box. Number of ''autocomplete'' products to display Change number of visible results shown in autocomplete dropdown when searching. Your file successfully uploaded! Include short description in compare products Check to display product short description on the compare products page. Include full description in compare products Check to display product full description on the compare products page. Short description Full description Allow guests to email their wishlists Check to allow guests to email their wishlists to friends. nopCommerce administration Image file that will be displayed in PDF order invoices. A small image is recommended. Allow ''out of stock'' items to be added to wishlist Check to allow ''out of stock'' products to be added to wishlist. ''Company'' required Check if ''Company'' is required. ''Street address'' required Check if ''Street address'' is required. ''Street address 2'' required Check if ''Street address 2'' is required. ''Zip / postal code'' required Check if ''Zip / postal code'' is required. ''City'' required Check if ''City'' is required. ''Phone number'' required Check if ''Phone number'' is required. ''Fax number'' required Check if ''Fax number'' is required Company name is required Street address is required Street address 2 is required Zip / postal code is required City is required Phone is required Fax is required Company name is required Street address is required Street address 2 is required Zip / postal code is required City is required Phone is required Fax is required Friendly name System name Display order Configure Is active Widget zone Choose widget zone Full-Text settings Full-Text is supported by your database Full-Text is not supported by your database Full-Text support has been enabled successfully. Full-Text support has been disabled successfully. Enable Full-Text Disable Full-Text Full-Text is enabled Full-Text is disabled Exact match (using CONTAINS with prefix_term) Using CONTAINS and OR with prefix_term Using CONTAINS and AND with prefix_term Search mode Choose Full-Text search mode Total weight Shipment total weight. Enabled Check to enable SMS provider Enabled Check to enable SMS provider Account Association: Your new user account will be linked to Encryption key changed Encryption private key must be 16 characters long The new encryption key is the same as the old one SSL settings SSL settings can also be changed in web.config file. Allow guests to vote Check to allow guests to vote. ID Upload a file Drop files here to upload Cancel Failed Number of manufacturers to display Enter the number of manufacturers to display in manufacturer navigation block. View all All product tags All product tags Item weight Item dimensions SKU Allowed quantities Enter a comma separated list of quantities you want this product variant to be restricted to. Instead of a quantity textbox that allows them to enter any quantity, they will receive a dropdown list of the values you enter here. Allowed quantities for this product: {0} Deleting abandoned shopping carts Created before Delete shopping cart items created before the specified date. {0} items were deleted Show product images in autocomplete box Determines whether product images should be displayed in the autocomplete search box. Activity Log Activity Log Type Comment Created on State / province If an asterisk is selected, then this shipping rate will apply to all customers from the given country, regardless of the state. Zip Zip / postal code. If zip is empty, then this shipping rate will apply to all customers from the given country or state, regardless of the zip code. Purchase Order Number Purchase Order Number: {0} Placed a new order (ID = {0}) Public store. Viewed a category details page (''{0}'') Public store. Viewed a manufacturer details page (''{0}'') Public store. Viewed a product details page (''{0}'') Expire month is required Expire year is required Manufacturers ' 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 --Update stored procedure according to the new search parameters (return filterable specs) IF EXISTS ( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ProductLoadAllPaged]') AND OBJECTPROPERTY(object_id,N'IsProcedure') = 1) DROP PROCEDURE [ProductLoadAllPaged] GO CREATE PROCEDURE [ProductLoadAllPaged] ( @CategoryIds nvarchar(MAX) = null, --a list of category IDs (comma-separated list). e.g. 1,2,3 @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(MAX) = null, --filter by attributes (comma-separated list). e.g. 14,15,16 @LanguageId int = 0, @OrderBy int = 0, --0 position, 5 - Name: A to Z, 6 - Name: Z to A, 10 - Price: Low to High, 11 - Price: High to Low, 15 - creation date @PageIndex int = 0, @PageSize int = 2147483644, @ShowHidden bit = 0, @LoadFilterableSpecificationAttributeOptionIds bit = 0, --a value indicating whether we should load the specification attribute option identifiers applied to loaded products (all pages) @FilterableSpecificationAttributeOptionIds nvarchar(MAX) = null OUTPUT, --the specification attribute option identifiers applied to loaded products (all pages). returned as a comma separated list of identifiers @TotalRecords int = null OUTPUT ) AS BEGIN /* Products that filtered by keywords */ CREATE TABLE #KeywordProducts ( [ProductId] int NOT NULL ) DECLARE @SearchKeywords bit, @sql nvarchar(max), @sql_orderby nvarchar(max) SET NOCOUNT ON --filter by keywords IF ISNULL(@Keywords, '') != '' BEGIN SET @SearchKeywords = 1 SET @Keywords = isnull(@Keywords, '') SET @Keywords = '%' + rtrim(ltrim(@Keywords)) + '%' SET @sql = ' INSERT INTO #KeywordProducts ([ProductId]) SELECT p.Id FROM Product p with (NOLOCK) WHERE PATINDEX(@Keywords, p.name) > 0 UNION SELECT pv.ProductId FROM ProductVariant pv with (NOLOCK) WHERE PATINDEX(@Keywords, pv.name) > 0 UNION SELECT pv.ProductId FROM ProductVariant pv with (NOLOCK) WHERE PATINDEX(@Keywords, pv.sku) > 0 UNION SELECT lp.EntityId FROM LocalizedProperty lp with (NOLOCK) WHERE lp.LocaleKeyGroup = N''Product'' AND lp.LanguageId = ' + ISNULL(CAST(@LanguageId AS nvarchar(max)), '0') + ' AND lp.LocaleKey = N''Name'' AND PATINDEX(@Keywords, lp.LocaleValue) > 0' IF @SearchDescriptions = 1 SET @sql = @sql + ' UNION SELECT p.Id FROM Product p with (NOLOCK) WHERE PATINDEX(@Keywords, p.ShortDescription) > 0 UNION SELECT p.Id FROM Product p with (NOLOCK) WHERE PATINDEX(@Keywords, p.FullDescription) > 0 UNION SELECT pv.ProductId FROM ProductVariant pv with (NOLOCK) WHERE PATINDEX(@Keywords, pv.Description) > 0 UNION SELECT lp.EntityId FROM LocalizedProperty lp with (NOLOCK) WHERE lp.LocaleKeyGroup = N''Product'' AND lp.LanguageId = ' + ISNULL(CAST(@LanguageId AS nvarchar(max)), '0') + ' AND lp.LocaleKey = N''ShortDescription'' AND PATINDEX(@Keywords, lp.LocaleValue) > 0 UNION SELECT lp.EntityId FROM LocalizedProperty lp with (NOLOCK) WHERE lp.LocaleKeyGroup = N''Product'' AND lp.LanguageId = ' + ISNULL(CAST(@LanguageId AS nvarchar(max)), '0') + ' AND lp.LocaleKey = N''FullDescription'' AND PATINDEX(@Keywords, lp.LocaleValue) > 0' --PRINT (@sql) EXEC sp_executesql @sql, N'@Keywords nvarchar(MAX)', @Keywords END ELSE BEGIN SET @SearchKeywords = 0 END --filter by category IDs SET @CategoryIds = isnull(@CategoryIds, '') CREATE TABLE #FilteredCategoryIds ( CategoryId int not null ) INSERT INTO #FilteredCategoryIds (CategoryId) SELECT CAST(data as int) FROM [nop_splitstring_to_table](@CategoryIds, ',') DECLARE @CategoryIdsCount int SET @CategoryIdsCount = (SELECT COUNT(1) FROM #FilteredCategoryIds) --filter by attributes SET @FilteredSpecs = isnull(@FilteredSpecs, '') CREATE TABLE #FilteredSpecs ( SpecificationAttributeOptionId int not null ) INSERT INTO #FilteredSpecs (SpecificationAttributeOptionId) SELECT CAST(data as int) FROM [nop_splitstring_to_table](@FilteredSpecs, ',') DECLARE @SpecAttributesCount int SET @SpecAttributesCount = (SELECT 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 ) SET @sql = ' INSERT INTO #DisplayOrderTmp ([ProductId]) SELECT p.Id FROM Product p with (NOLOCK)' IF @CategoryIdsCount > 0 BEGIN SET @sql = @sql + ' LEFT JOIN Product_Category_Mapping pcm with (NOLOCK) ON p.Id = pcm.ProductId' END IF @ManufacturerId > 0 BEGIN SET @sql = @sql + ' LEFT JOIN Product_Manufacturer_Mapping pmm with (NOLOCK) ON p.Id = pmm.ProductId' END IF ISNULL(@ProductTagId, 0) != 0 BEGIN SET @sql = @sql + ' LEFT JOIN Product_ProductTag_Mapping pptm with (NOLOCK) ON p.Id = pptm.Product_Id' END IF @ShowHidden = 0 OR @PriceMin > 0 OR @PriceMax > 0 OR @OrderBy = 10 /* Price: Low to High */ OR @OrderBy = 11 /* Price: High to Low */ BEGIN SET @sql = @sql + ' LEFT JOIN ProductVariant pv with (NOLOCK) ON p.Id = pv.ProductId' END --searching by keywords IF @SearchKeywords = 1 BEGIN SET @sql = @sql + ' JOIN #KeywordProducts kp ON p.Id = kp.ProductId' END SET @sql = @sql + ' WHERE p.Deleted = 0' --filter by category IF @CategoryIdsCount > 0 BEGIN SET @sql = @sql + ' AND pcm.CategoryId IN (SELECT CategoryId FROM #FilteredCategoryIds)' IF @FeaturedProducts IS NOT NULL BEGIN SET @sql = @sql + ' AND pcm.IsFeaturedProduct = ' + CAST(@FeaturedProducts AS nvarchar(max)) END END --filter by manufacturer IF @ManufacturerId > 0 BEGIN SET @sql = @sql + ' AND pmm.ManufacturerId = ' + CAST(@ManufacturerId AS nvarchar(max)) IF @FeaturedProducts IS NOT NULL BEGIN SET @sql = @sql + ' AND pmm.IsFeaturedProduct = ' + CAST(@FeaturedProducts AS nvarchar(max)) END END --filter by product tag IF ISNULL(@ProductTagId, 0) != 0 BEGIN SET @sql = @sql + ' AND pptm.ProductTag_Id = ' + CAST(@ProductTagId AS nvarchar(max)) END IF @ShowHidden = 0 BEGIN SET @sql = @sql + ' AND p.Published = 1 AND pv.Published = 1 AND pv.Deleted = 0 AND (getutcdate() BETWEEN ISNULL(pv.AvailableStartDateTimeUtc, ''1/1/1900'') and ISNULL(pv.AvailableEndDateTimeUtc, ''1/1/2999''))' END --min price IF @PriceMin > 0 BEGIN SET @sql = @sql + ' AND ( ( --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 >= ' + CAST(@PriceMin AS nvarchar(max)) + ') ) OR ( --regular price (price isnt specified or date range isnt 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 >= ' + CAST(@PriceMin AS nvarchar(max)) + ') ) )' END --max price IF @PriceMax > 0 BEGIN SET @sql = @sql + ' AND ( ( --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 <= ' + CAST(@PriceMax AS nvarchar(max)) + ') ) OR ( --regular price (price isnt specified or date range isnt 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 <= ' + CAST(@PriceMax AS nvarchar(max)) + ') ) )' END --filter by specs IF @SpecAttributesCount > 0 BEGIN SET @sql = @sql + ' AND NOT EXISTS ( SELECT 1 FROM #FilteredSpecs [fs] WHERE [fs].SpecificationAttributeOptionId NOT IN ( SELECT psam.SpecificationAttributeOptionId FROM Product_SpecificationAttribute_Mapping psam WHERE psam.AllowFiltering = 1 AND psam.ProductId = p.Id ) )' END --sorting SET @sql_orderby = '' IF @OrderBy = 5 /* Name: A to Z */ SET @sql_orderby = ' p.[Name] ASC' ELSE IF @OrderBy = 6 /* Name: Z to A */ SET @sql_orderby = ' p.[Name] DESC' ELSE IF @OrderBy = 10 /* Price: Low to High */ SET @sql_orderby = ' pv.[Price] ASC' ELSE IF @OrderBy = 11 /* Price: High to Low */ SET @sql_orderby = ' pv.[Price] DESC' ELSE IF @OrderBy = 15 /* creation date */ SET @sql_orderby = ' p.[CreatedOnUtc] DESC' ELSE /* default sorting, 0 (position) */ BEGIN --category position (display order) IF @CategoryIdsCount > 0 SET @sql_orderby = ' pcm.DisplayOrder ASC' --manufacturer position (display order) IF @ManufacturerId > 0 BEGIN IF LEN(@sql_orderby) > 0 SET @sql_orderby = @sql_orderby + ', ' SET @sql_orderby = @sql_orderby + ' pmm.DisplayOrder ASC' END --name IF LEN(@sql_orderby) > 0 SET @sql_orderby = @sql_orderby + ', ' SET @sql_orderby = @sql_orderby + ' p.[Name] ASC' END SET @sql = @sql + ' ORDER BY' + @sql_orderby --PRINT (@sql) EXEC sp_executesql @sql DROP TABLE #FilteredCategoryIds 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 GROUP BY ProductId ORDER BY min([Id]) --total records SET @TotalRecords = @@rowcount DROP TABLE #DisplayOrderTmp --prepare filterable specification attribute option identifier (if requested) IF @LoadFilterableSpecificationAttributeOptionIds = 1 BEGIN CREATE TABLE #FilterableSpecs ( [SpecificationAttributeOptionId] int NOT NULL ) INSERT INTO #FilterableSpecs ([SpecificationAttributeOptionId]) SELECT DISTINCT [psam].SpecificationAttributeOptionId FROM [Product_SpecificationAttribute_Mapping] [psam] WHERE [psam].[AllowFiltering] = 1 AND [psam].[ProductId] IN (SELECT [pi].ProductId FROM #PageIndex [pi]) --build comma separated list of filterable identifiers SELECT @FilterableSpecificationAttributeOptionIds = COALESCE(@FilterableSpecificationAttributeOptionIds + ',' , '') + CAST(SpecificationAttributeOptionId as nvarchar(1000)) FROM #FilterableSpecs DROP TABLE #FilterableSpecs END --return products SELECT TOP (@RowsToReturn) p.* FROM #PageIndex [pi] INNER JOIN Product p on p.Id = [pi].[ProductId] WHERE [pi].IndexId > @PageLowerBound AND [pi].IndexId < @PageUpperBound ORDER BY [pi].IndexId DROP TABLE #PageIndex END GO IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[nop_splitstring_to_table]') AND [type] in (N'FN', N'IF', N'TF')) DROP FUNCTION [nop_splitstring_to_table] GO CREATE FUNCTION [dbo].[nop_splitstring_to_table] ( @string NVARCHAR(MAX), @delimiter CHAR(1) ) RETURNS @output TABLE( data NVARCHAR(MAX) ) BEGIN DECLARE @start INT, @end INT SELECT @start = 1, @end = CHARINDEX(@delimiter, @string) WHILE @start < LEN(@string) + 1 BEGIN IF @end = 0 SET @end = LEN(@string) + 1 INSERT INTO @output (data) VALUES(SUBSTRING(@string, @start, @end - @start)) SET @start = @end + 1 SET @end = CHARINDEX(@delimiter, @string, @start) END RETURN END GO --Add 'StartDateUtc' and 'EndDateUtc' columns to [News] table IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[News]') and NAME='StartDateUtc') BEGIN ALTER TABLE [News] ADD [StartDateUtc] datetime NULL END GO IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[News]') and NAME='EndDateUtc') BEGIN ALTER TABLE [News] ADD [EndDateUtc] datetime NULL END GO --Add 'StartDateUtc' and 'EndDateUtc' columns to [BlogPost] table IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[BlogPost]') and NAME='StartDateUtc') BEGIN ALTER TABLE [BlogPost] ADD [StartDateUtc] datetime NULL END GO IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[BlogPost]') and NAME='EndDateUtc') BEGIN ALTER TABLE [BlogPost] ADD [EndDateUtc] datetime NULL END GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'customersettings.defaultpasswordformat') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'customersettings.defaultpasswordformat', N'Hashed') END GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'commonsettings.displayjavascriptdisabledwarning') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'commonsettings.displayjavascriptdisabledwarning', N'false') END GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'captchasettings.showonblogcommentpage') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'captchasettings.showonblogcommentpage', N'false') END GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'captchasettings.showonnewscommentpage') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'captchasettings.showonnewscommentpage', N'false') END GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'captchasettings.showonproductreviewpage') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'captchasettings.showonproductreviewpage', N'false') END GO --Add 'CreatedOnUtc' column to [Shipment] table IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[Shipment]') and NAME='CreatedOnUtc') BEGIN ALTER TABLE [Shipment] ADD [CreatedOnUtc] datetime NULL exec('UPDATE [Shipment] SET [CreatedOnUtc] = [ShippedDateUtc]') END GO ALTER TABLE [Shipment] ALTER COLUMN [CreatedOnUtc] datetime NOT NULL GO --Created shipments should not be immediately shipped ALTER TABLE [Shipment] ALTER COLUMN [ShippedDateUtc] datetime NULL GO --Store comment count in [News] entity/table IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[News]') and NAME='ApprovedCommentCount') BEGIN ALTER TABLE [News] ADD [ApprovedCommentCount] int NULL END GO IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[News]') and NAME='NotApprovedCommentCount') BEGIN ALTER TABLE [News] ADD [NotApprovedCommentCount] int NULL END GO EXEC(' DECLARE @NewsId int DECLARE cur_news CURSOR FOR SELECT [Id] FROM [News] ORDER BY [Id] OPEN cur_news FETCH NEXT FROM cur_news INTO @NewsId WHILE @@FETCH_STATUS = 0 BEGIN DECLARE @ApprovedCommentCount int DECLARE @NotApprovedCommentCount int SET @ApprovedCommentCount = null -- clear cache (variable scope) SET @NotApprovedCommentCount = null -- clear cache (variable scope) SELECT @ApprovedCommentCount = COUNT(1) FROM [NewsComment] as [nc] INNER JOIN [CustomerContent] AS [cc] ON [nc].[Id] = [cc].[Id] WHERE [nc].[NewsItemId] = @NewsId AND [cc].[IsApproved]=1 SELECT @NotApprovedCommentCount = COUNT(1) FROM [NewsComment] as [nc] INNER JOIN [CustomerContent] AS [cc] ON [nc].[Id] = [cc].[Id] WHERE [nc].[NewsItemId] = @NewsId AND [cc].[IsApproved]=0 UPDATE [News] SET [ApprovedCommentCount] = @ApprovedCommentCount, [NotApprovedCommentCount] = @NotApprovedCommentCount WHERE [Id] = @NewsId --fetch next identifier FETCH NEXT FROM cur_news INTO @NewsId END CLOSE cur_news DEALLOCATE cur_news ') GO ALTER TABLE [News] ALTER COLUMN [ApprovedCommentCount] int NOT NULL GO ALTER TABLE [News] ALTER COLUMN [NotApprovedCommentCount] int NOT NULL GO --Store comment count in [BlogPost] entity/table IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[BlogPost]') and NAME='ApprovedCommentCount') BEGIN ALTER TABLE [BlogPost] ADD [ApprovedCommentCount] int NULL END GO IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[BlogPost]') and NAME='NotApprovedCommentCount') BEGIN ALTER TABLE [BlogPost] ADD [NotApprovedCommentCount] int NULL END GO EXEC(' DECLARE @BlogPostId int DECLARE cur_blogpost CURSOR FOR SELECT [Id] FROM [BlogPost] ORDER BY [Id] OPEN cur_blogpost FETCH NEXT FROM cur_blogpost INTO @BlogPostId WHILE @@FETCH_STATUS = 0 BEGIN DECLARE @ApprovedCommentCount int DECLARE @NotApprovedCommentCount int SET @ApprovedCommentCount = null -- clear cache (variable scope) SET @NotApprovedCommentCount = null -- clear cache (variable scope) SELECT @ApprovedCommentCount = COUNT(1) FROM [BlogComment] as [nc] INNER JOIN [CustomerContent] AS [cc] ON [nc].[Id] = [cc].[Id] WHERE [nc].[BlogPostId] = @BlogPostId AND [cc].[IsApproved]=1 SELECT @NotApprovedCommentCount = COUNT(1) FROM [BlogComment] as [nc] INNER JOIN [CustomerContent] AS [cc] ON [nc].[Id] = [cc].[Id] WHERE [nc].[BlogPostId] = @BlogPostId AND [cc].[IsApproved]=0 UPDATE [BlogPost] SET [ApprovedCommentCount] = @ApprovedCommentCount, [NotApprovedCommentCount] = @NotApprovedCommentCount WHERE [Id] = @BlogPostId --fetch next identifier FETCH NEXT FROM cur_blogpost INTO @BlogPostId END CLOSE cur_blogpost DEALLOCATE cur_blogpost ') GO ALTER TABLE [BlogPost] ALTER COLUMN [ApprovedCommentCount] int NOT NULL GO ALTER TABLE [BlogPost] ALTER COLUMN [NotApprovedCommentCount] int NOT NULL GO --Store a value indicating whether we have tier prices in [ProductVariant] entity/table IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[ProductVariant]') and NAME='HasTierPrices') BEGIN ALTER TABLE [ProductVariant] ADD [HasTierPrices] bit NULL END GO EXEC(' DECLARE @ProductVariantId int DECLARE cur_productvariant CURSOR FOR SELECT [Id] FROM [ProductVariant] ORDER BY [Id] OPEN cur_productvariant FETCH NEXT FROM cur_productvariant INTO @ProductVariantId WHILE @@FETCH_STATUS = 0 BEGIN DECLARE @HasTierPrices bit SET @HasTierPrices = null -- clear cache (variable scope) IF (EXISTS (SELECT 1 FROM [TierPrice] as [tp] WHERE [tp].[ProductVariantId] = @ProductVariantId)) BEGIN SET @HasTierPrices = 1 END ELSE BEGIN SET @HasTierPrices = 0 END UPDATE [ProductVariant] SET [HasTierPrices] = @HasTierPrices WHERE [Id] = @ProductVariantId --fetch next identifier FETCH NEXT FROM cur_productvariant INTO @ProductVariantId END CLOSE cur_productvariant DEALLOCATE cur_productvariant ') GO ALTER TABLE [ProductVariant] ALTER COLUMN [HasTierPrices] bit NOT NULL GO DELETE FROM [Setting] WHERE [Name] = N'catalogsettings.ignoretierprices' GO --Store a value indicating whether we have discounts applied in [ProductVariant] entity/table IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[ProductVariant]') and NAME='HasDiscountsApplied') BEGIN ALTER TABLE [ProductVariant] ADD [HasDiscountsApplied] bit NULL END GO EXEC(' DECLARE @ProductVariantId int DECLARE cur_productvariant CURSOR FOR SELECT [Id] FROM [ProductVariant] ORDER BY [Id] OPEN cur_productvariant FETCH NEXT FROM cur_productvariant INTO @ProductVariantId WHILE @@FETCH_STATUS = 0 BEGIN DECLARE @HasDiscountsApplied bit SET @HasDiscountsApplied = null -- clear cache (variable scope) IF (EXISTS (SELECT 1 FROM [Discount_AppliedToProductVariants] as [datpv] WHERE [datpv].[ProductVariant_Id] = @ProductVariantId)) BEGIN SET @HasDiscountsApplied = 1 END ELSE BEGIN SET @HasDiscountsApplied = 0 END UPDATE [ProductVariant] SET [HasDiscountsApplied] = @HasDiscountsApplied WHERE [Id] = @ProductVariantId --fetch next identifier FETCH NEXT FROM cur_productvariant INTO @ProductVariantId END CLOSE cur_productvariant DEALLOCATE cur_productvariant ') GO ALTER TABLE [ProductVariant] ALTER COLUMN [HasDiscountsApplied] bit NOT NULL GO --Store a value indicating whether we have discounts applied in [ProductVariant] entity/table IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[ProductVariant]') and NAME='HasDiscountsApplied') BEGIN ALTER TABLE [ProductVariant] ADD [HasDiscountsApplied] bit NULL END GO EXEC(' DECLARE @ProductVariantId int DECLARE cur_productvariant CURSOR FOR SELECT [Id] FROM [ProductVariant] ORDER BY [Id] OPEN cur_productvariant FETCH NEXT FROM cur_productvariant INTO @ProductVariantId WHILE @@FETCH_STATUS = 0 BEGIN DECLARE @HasDiscountsApplied bit SET @HasDiscountsApplied = null -- clear cache (variable scope) IF (EXISTS (SELECT 1 FROM [Discount_AppliedToProductVariants] as [datpv] WHERE [datpv].[ProductVariant_Id] = @ProductVariantId)) BEGIN SET @HasDiscountsApplied = 1 END ELSE BEGIN SET @HasDiscountsApplied = 0 END UPDATE [ProductVariant] SET [HasDiscountsApplied] = @HasDiscountsApplied WHERE [Id] = @ProductVariantId --fetch next identifier FETCH NEXT FROM cur_productvariant INTO @ProductVariantId END CLOSE cur_productvariant DEALLOCATE cur_productvariant ') GO --Store a value indicating whether we have discounts applied in [Category] entity/table IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[Category]') and NAME='HasDiscountsApplied') BEGIN ALTER TABLE [Category] ADD [HasDiscountsApplied] bit NULL END GO EXEC(' DECLARE @CategoryId int DECLARE cur_category CURSOR FOR SELECT [Id] FROM [Category] ORDER BY [Id] OPEN cur_category FETCH NEXT FROM cur_category INTO @CategoryId WHILE @@FETCH_STATUS = 0 BEGIN DECLARE @HasDiscountsApplied bit SET @HasDiscountsApplied = null -- clear cache (variable scope) IF (EXISTS (SELECT 1 FROM [Discount_AppliedToCategories] as [datc] WHERE [datc].[Category_Id] = @CategoryId)) BEGIN SET @HasDiscountsApplied = 1 END ELSE BEGIN SET @HasDiscountsApplied = 0 END UPDATE [Category] SET [HasDiscountsApplied] = @HasDiscountsApplied WHERE [Id] = @CategoryId --fetch next identifier FETCH NEXT FROM cur_category INTO @CategoryId END CLOSE cur_category DEALLOCATE cur_category ') GO ALTER TABLE [Category] ALTER COLUMN [HasDiscountsApplied] bit NOT NULL GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'mediasettings.defaultimagequality') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'mediasettings.defaultimagequality', N'100') END GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'storeinformationsettings.displayeucookielawwarning') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'storeinformationsettings.displayeucookielawwarning', N'false') END GO --Tax By Country & State & Zip provider issue fix UPDATE [TaxRate] SET [Zip] = null WHERE [Zip] = N'*' GO --new generic attribute implementation IF NOT EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[GenericAttribute]') and OBJECTPROPERTY(object_id, N'IsUserTable') = 1) BEGIN CREATE TABLE [dbo].[GenericAttribute]( [Id] [int] IDENTITY(1,1) NOT NULL, [EntityId] [int] NOT NULL, [KeyGroup] nvarchar(400) NOT NULL, [Key] nvarchar(400) NOT NULL, [Value] nvarchar(MAX) 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 object_id = OBJECT_ID(N'[CustomerAttribute]') and OBJECTPROPERTY(object_id, N'IsUserTable') = 1) BEGIN --move customer attributes to the new generic attributes EXEC(' DECLARE @CustomerAttributeId int DECLARE cur_customerattribute CURSOR FOR SELECT [Id] FROM [CustomerAttribute] ORDER BY [Id] OPEN cur_customerattribute FETCH NEXT FROM cur_customerattribute INTO @CustomerAttributeId WHILE @@FETCH_STATUS = 0 BEGIN DECLARE @AttributeCustomerId int DECLARE @AttributeKey nvarchar(MAX) DECLARE @AttributeValue nvarchar(MAX) SET @AttributeCustomerId = null -- clear cache (variable scope) SET @AttributeKey = null -- clear cache (variable scope) SET @AttributeValue = null -- clear cache (variable scope) SELECT @AttributeCustomerId = [CustomerId], @AttributeKey = [Key], @AttributeValue = [Value] FROM [CustomerAttribute] WHERE [Id]=@CustomerAttributeId --insert new generic attribute INSERT INTO [GenericAttribute] ([EntityId], [KeyGroup], [Key], [Value]) VALUES (@AttributeCustomerId, N''Customer'', @AttributeKey, @AttributeValue) --fetch next identifier FETCH NEXT FROM cur_customerattribute INTO @CustomerAttributeId END CLOSE cur_customerattribute DEALLOCATE cur_customerattribute ') DROP TABLE [CustomerAttribute] END GO --more SQL indexes IF NOT EXISTS (SELECT 1 from sys.indexes WHERE [NAME]=N'IX_GenericAttribute_EntityId_and_KeyGroup' and object_id=object_id(N'[GenericAttribute]')) BEGIN CREATE NONCLUSTERED INDEX [IX_GenericAttribute_EntityId_and_KeyGroup] ON [GenericAttribute] ( [EntityId] ASC, [KeyGroup] ASC ) END GO DELETE FROM [Setting] WHERE [Name] = N'shoppingcartsettings.minishoppingcartdisplayproducts' GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'shoppingcartsettings.minishoppingcartproductnumber') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'shoppingcartsettings.minishoppingcartproductnumber', N'5') END GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'shoppingcartsettings.showproductimagesinminishoppingcart') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'shoppingcartsettings.showproductimagesinminishoppingcart', N'true') END GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'mediasettings.minicartthumbpicturesize') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'mediasettings.minicartthumbpicturesize', N'47') END GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'catalogsettings.productsearchautocompleteenabled') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'catalogsettings.productsearchautocompleteenabled', N'true') END GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'catalogsettings.productsearchautocompletenumberofproducts') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'catalogsettings.productsearchautocompletenumberofproducts', N'10') END GO --new 'permission records IF NOT EXISTS ( SELECT 1 FROM [PermissionRecord] WHERE [SystemName] = N'PublicStoreAllowNavigation') BEGIN INSERT [PermissionRecord] ([Name], [SystemName], [Category]) VALUES (N'Public store. Allow navigation', N'PublicStoreAllowNavigation', 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 [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 [Setting] WHERE [name] = N'catalogsettings.includeshortdescriptionincompareproducts') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'catalogsettings.includeshortdescriptionincompareproducts', N'false') END GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'catalogsettings.includefulldescriptionincompareproducts') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'catalogsettings.includefulldescriptionincompareproducts', N'false') END GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'shoppingcartsettings.allowanonymoususerstoemailwishlist') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'shoppingcartsettings.allowanonymoususerstoemailwishlist', N'false') END GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'shoppingcartsettings.allowoutofstockitemstobeaddedtowishlist') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'shoppingcartsettings.allowoutofstockitemstobeaddedtowishlist', N'false') END GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'customersettings.companyrequired') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'customersettings.companyrequired', N'false') END GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'customersettings.streetaddressrequired') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'customersettings.streetaddressrequired', N'false') END GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'customersettings.streetaddress2required') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'customersettings.streetaddress2required', N'false') END GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'customersettings.zippostalcoderequired') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'customersettings.zippostalcoderequired', N'false') END GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'customersettings.cityrequired') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'customersettings.cityrequired', N'false') END GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'customersettings.phonerequired') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'customersettings.phonerequired', N'false') END GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'customersettings.faxrequired') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'customersettings.faxrequired', N'false') END GO --new widget implementation IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[Widget]') and OBJECTPROPERTY(object_id, N'IsUserTable') = 1) BEGIN DROP TABLE [Widget] END GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'widgetsettings.activewidgetsystemnames') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'widgetsettings.activewidgetsystemnames', N'') END GO --Full-text support IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'commonsettings.usefulltextsearch') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'commonsettings.usefulltextsearch', N'false') END GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'commonsettings.fulltextsearchmode') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'commonsettings.fulltextsearchmode', N'ExactMatch') END GO IF EXISTS ( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ProductLoadAllPaged]') AND OBJECTPROPERTY(object_id,N'IsProcedure') = 1) DROP PROCEDURE [ProductLoadAllPaged] GO CREATE PROCEDURE [ProductLoadAllPaged] ( @CategoryIds nvarchar(MAX) = null, --a list of category IDs (comma-separated list). e.g. 1,2,3 @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(4000) = null, @SearchDescriptions bit = 0, @UseFullTextSearch bit = 0, @FullTextMode int = 0, --0 using CONTAINS with , 5 - using CONTAINS and OR with , 10 - using CONTAINS and AND with @FilteredSpecs nvarchar(MAX) = null, --filter by attributes (comma-separated list). e.g. 14,15,16 @LanguageId int = 0, @OrderBy int = 0, --0 position, 5 - Name: A to Z, 6 - Name: Z to A, 10 - Price: Low to High, 11 - Price: High to Low, 15 - creation date @PageIndex int = 0, @PageSize int = 2147483644, @ShowHidden bit = 0, @LoadFilterableSpecificationAttributeOptionIds bit = 0, --a value indicating whether we should load the specification attribute option identifiers applied to loaded products (all pages) @FilterableSpecificationAttributeOptionIds nvarchar(MAX) = null OUTPUT, --the specification attribute option identifiers applied to loaded products (all pages). returned as a comma separated list of identifiers @TotalRecords int = null OUTPUT ) AS BEGIN /* Products that filtered by keywords */ CREATE TABLE #KeywordProducts ( [ProductId] int NOT NULL ) DECLARE @SearchKeywords bit, @sql nvarchar(max), @sql_orderby nvarchar(max) SET NOCOUNT ON --filter by keywords SET @Keywords = isnull(@Keywords, '') SET @Keywords = rtrim(ltrim(@Keywords)) IF ISNULL(@Keywords, '') != '' BEGIN SET @SearchKeywords = 1 IF @UseFullTextSearch = 1 BEGIN --full-text search IF @FullTextMode = 0 BEGIN --0 - using CONTAINS with SET @Keywords = ' "' + @Keywords + '*" ' END ELSE BEGIN --5 - using CONTAINS and OR with --10 - using CONTAINS and AND with --remove wrong chars (' ") SET @Keywords = REPLACE(@Keywords, '''', '') SET @Keywords = REPLACE(@Keywords, '"', '') --clean multiple spaces WHILE CHARINDEX(' ', @Keywords) > 0 SET @Keywords = REPLACE(@Keywords, ' ', ' ') DECLARE @concat_term nvarchar(100) IF @FullTextMode = 5 --5 - using CONTAINS and OR with BEGIN SET @concat_term = 'OR' END IF @FullTextMode = 10 --10 - using CONTAINS and AND with BEGIN SET @concat_term = 'AND' END --now let's build search string declare @fulltext_keywords nvarchar(4000) set @fulltext_keywords = N'' declare @index int set @index = CHARINDEX(' ', @Keywords, 0) -- if index = 0, then only one field was passed IF(@index = 0) set @fulltext_keywords = ' "' + @Keywords + '*" ' ELSE BEGIN DECLARE @first BIT SET @first = 1 WHILE @index > 0 BEGIN IF (@first = 0) SET @fulltext_keywords = @fulltext_keywords + ' ' + @concat_term + ' ' ELSE SET @first = 0 SET @fulltext_keywords = @fulltext_keywords + '"' + SUBSTRING(@Keywords, 1, @index - 1) + '*"' SET @Keywords = SUBSTRING(@Keywords, @index + 1, LEN(@Keywords) - @index) SET @index = CHARINDEX(' ', @Keywords, 0) end -- add the last field IF LEN(@fulltext_keywords) > 0 SET @fulltext_keywords = @fulltext_keywords + ' ' + @concat_term + ' ' + '"' + SUBSTRING(@Keywords, 1, LEN(@Keywords)) + '*"' END SET @Keywords = @fulltext_keywords END END ELSE BEGIN --usual search by PATINDEX SET @Keywords = '%' + @Keywords + '%' END --PRINT @Keywords --product name SET @sql = ' INSERT INTO #KeywordProducts ([ProductId]) SELECT p.Id FROM Product p with (NOLOCK) WHERE ' IF @UseFullTextSearch = 1 SET @sql = @sql + 'CONTAINS(p.[Name], @Keywords) ' ELSE SET @sql = @sql + 'PATINDEX(@Keywords, p.[Name]) > 0 ' --product variant name SET @sql = @sql + ' UNION SELECT pv.ProductId FROM ProductVariant pv with (NOLOCK) WHERE ' IF @UseFullTextSearch = 1 SET @sql = @sql + 'CONTAINS(pv.[Name], @Keywords) ' ELSE SET @sql = @sql + 'PATINDEX(@Keywords, pv.[Name]) > 0 ' --SKU SET @sql = @sql + ' UNION SELECT pv.ProductId FROM ProductVariant pv with (NOLOCK) WHERE ' IF @UseFullTextSearch = 1 SET @sql = @sql + 'CONTAINS(pv.[Sku], @Keywords) ' ELSE SET @sql = @sql + 'PATINDEX(@Keywords, pv.[Sku]) > 0 ' --localized product name SET @sql = @sql + ' UNION SELECT lp.EntityId FROM LocalizedProperty lp with (NOLOCK) WHERE lp.LocaleKeyGroup = N''Product'' AND lp.LanguageId = ' + ISNULL(CAST(@LanguageId AS nvarchar(max)), '0') + ' AND lp.LocaleKey = N''Name''' IF @UseFullTextSearch = 1 SET @sql = @sql + ' AND CONTAINS(lp.[LocaleValue], @Keywords) ' ELSE SET @sql = @sql + ' AND PATINDEX(@Keywords, lp.[LocaleValue]) > 0 ' --product short description IF @SearchDescriptions = 1 BEGIN SET @sql = @sql + ' UNION SELECT p.Id FROM Product p with (NOLOCK) WHERE ' IF @UseFullTextSearch = 1 SET @sql = @sql + 'CONTAINS(p.[ShortDescription], @Keywords) ' ELSE SET @sql = @sql + 'PATINDEX(@Keywords, p.[ShortDescription]) > 0 ' --product full description SET @sql = @sql + ' UNION SELECT p.Id FROM Product p with (NOLOCK) WHERE ' IF @UseFullTextSearch = 1 SET @sql = @sql + 'CONTAINS(p.[FullDescription], @Keywords) ' ELSE SET @sql = @sql + 'PATINDEX(@Keywords, p.[FullDescription]) > 0 ' --product variant description SET @sql = @sql + ' UNION SELECT pv.ProductId FROM ProductVariant pv with (NOLOCK) WHERE ' IF @UseFullTextSearch = 1 SET @sql = @sql + 'CONTAINS(pv.[Description], @Keywords) ' ELSE SET @sql = @sql + 'PATINDEX(@Keywords, pv.[Description]) > 0 ' --localized product short description SET @sql = @sql + ' UNION SELECT lp.EntityId FROM LocalizedProperty lp with (NOLOCK) WHERE lp.LocaleKeyGroup = N''Product'' AND lp.LanguageId = ' + ISNULL(CAST(@LanguageId AS nvarchar(max)), '0') + ' AND lp.LocaleKey = N''ShortDescription''' IF @UseFullTextSearch = 1 SET @sql = @sql + ' AND CONTAINS(lp.[LocaleValue], @Keywords) ' ELSE SET @sql = @sql + ' AND PATINDEX(@Keywords, lp.[LocaleValue]) > 0 ' --localized product full description SET @sql = @sql + ' UNION SELECT lp.EntityId FROM LocalizedProperty lp with (NOLOCK) WHERE lp.LocaleKeyGroup = N''Product'' AND lp.LanguageId = ' + ISNULL(CAST(@LanguageId AS nvarchar(max)), '0') + ' AND lp.LocaleKey = N''FullDescription''' IF @UseFullTextSearch = 1 SET @sql = @sql + ' AND CONTAINS(lp.[LocaleValue], @Keywords) ' ELSE SET @sql = @sql + ' AND PATINDEX(@Keywords, lp.[LocaleValue]) > 0 ' END --PRINT (@sql) EXEC sp_executesql @sql, N'@Keywords nvarchar(4000)', @Keywords END ELSE BEGIN SET @SearchKeywords = 0 END --filter by category IDs SET @CategoryIds = isnull(@CategoryIds, '') CREATE TABLE #FilteredCategoryIds ( CategoryId int not null ) INSERT INTO #FilteredCategoryIds (CategoryId) SELECT CAST(data as int) FROM [nop_splitstring_to_table](@CategoryIds, ',') DECLARE @CategoryIdsCount int SET @CategoryIdsCount = (SELECT COUNT(1) FROM #FilteredCategoryIds) --filter by attributes SET @FilteredSpecs = isnull(@FilteredSpecs, '') CREATE TABLE #FilteredSpecs ( SpecificationAttributeOptionId int not null ) INSERT INTO #FilteredSpecs (SpecificationAttributeOptionId) SELECT CAST(data as int) FROM [nop_splitstring_to_table](@FilteredSpecs, ',') DECLARE @SpecAttributesCount int SET @SpecAttributesCount = (SELECT 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 ) SET @sql = ' INSERT INTO #DisplayOrderTmp ([ProductId]) SELECT p.Id FROM Product p with (NOLOCK)' IF @CategoryIdsCount > 0 BEGIN SET @sql = @sql + ' LEFT JOIN Product_Category_Mapping pcm with (NOLOCK) ON p.Id = pcm.ProductId' END IF @ManufacturerId > 0 BEGIN SET @sql = @sql + ' LEFT JOIN Product_Manufacturer_Mapping pmm with (NOLOCK) ON p.Id = pmm.ProductId' END IF ISNULL(@ProductTagId, 0) != 0 BEGIN SET @sql = @sql + ' LEFT JOIN Product_ProductTag_Mapping pptm with (NOLOCK) ON p.Id = pptm.Product_Id' END IF @ShowHidden = 0 OR @PriceMin > 0 OR @PriceMax > 0 OR @OrderBy = 10 /* Price: Low to High */ OR @OrderBy = 11 /* Price: High to Low */ BEGIN SET @sql = @sql + ' LEFT JOIN ProductVariant pv with (NOLOCK) ON p.Id = pv.ProductId' END --searching by keywords IF @SearchKeywords = 1 BEGIN SET @sql = @sql + ' JOIN #KeywordProducts kp ON p.Id = kp.ProductId' END SET @sql = @sql + ' WHERE p.Deleted = 0' --filter by category IF @CategoryIdsCount > 0 BEGIN SET @sql = @sql + ' AND pcm.CategoryId IN (SELECT CategoryId FROM #FilteredCategoryIds)' IF @FeaturedProducts IS NOT NULL BEGIN SET @sql = @sql + ' AND pcm.IsFeaturedProduct = ' + CAST(@FeaturedProducts AS nvarchar(max)) END END --filter by manufacturer IF @ManufacturerId > 0 BEGIN SET @sql = @sql + ' AND pmm.ManufacturerId = ' + CAST(@ManufacturerId AS nvarchar(max)) IF @FeaturedProducts IS NOT NULL BEGIN SET @sql = @sql + ' AND pmm.IsFeaturedProduct = ' + CAST(@FeaturedProducts AS nvarchar(max)) END END --filter by product tag IF ISNULL(@ProductTagId, 0) != 0 BEGIN SET @sql = @sql + ' AND pptm.ProductTag_Id = ' + CAST(@ProductTagId AS nvarchar(max)) END IF @ShowHidden = 0 BEGIN SET @sql = @sql + ' AND p.Published = 1 AND pv.Published = 1 AND pv.Deleted = 0 AND (getutcdate() BETWEEN ISNULL(pv.AvailableStartDateTimeUtc, ''1/1/1900'') and ISNULL(pv.AvailableEndDateTimeUtc, ''1/1/2999''))' END --min price IF @PriceMin > 0 BEGIN SET @sql = @sql + ' AND ( ( --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 >= ' + CAST(@PriceMin AS nvarchar(max)) + ') ) OR ( --regular price (price isnt specified or date range isnt 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 >= ' + CAST(@PriceMin AS nvarchar(max)) + ') ) )' END --max price IF @PriceMax > 0 BEGIN SET @sql = @sql + ' AND ( ( --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 <= ' + CAST(@PriceMax AS nvarchar(max)) + ') ) OR ( --regular price (price isnt specified or date range isnt 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 <= ' + CAST(@PriceMax AS nvarchar(max)) + ') ) )' END --filter by specs IF @SpecAttributesCount > 0 BEGIN SET @sql = @sql + ' AND NOT EXISTS ( SELECT 1 FROM #FilteredSpecs [fs] WHERE [fs].SpecificationAttributeOptionId NOT IN ( SELECT psam.SpecificationAttributeOptionId FROM Product_SpecificationAttribute_Mapping psam WHERE psam.AllowFiltering = 1 AND psam.ProductId = p.Id ) )' END --sorting SET @sql_orderby = '' IF @OrderBy = 5 /* Name: A to Z */ SET @sql_orderby = ' p.[Name] ASC' ELSE IF @OrderBy = 6 /* Name: Z to A */ SET @sql_orderby = ' p.[Name] DESC' ELSE IF @OrderBy = 10 /* Price: Low to High */ SET @sql_orderby = ' pv.[Price] ASC' ELSE IF @OrderBy = 11 /* Price: High to Low */ SET @sql_orderby = ' pv.[Price] DESC' ELSE IF @OrderBy = 15 /* creation date */ SET @sql_orderby = ' p.[CreatedOnUtc] DESC' ELSE /* default sorting, 0 (position) */ BEGIN --category position (display order) IF @CategoryIdsCount > 0 SET @sql_orderby = ' pcm.DisplayOrder ASC' --manufacturer position (display order) IF @ManufacturerId > 0 BEGIN IF LEN(@sql_orderby) > 0 SET @sql_orderby = @sql_orderby + ', ' SET @sql_orderby = @sql_orderby + ' pmm.DisplayOrder ASC' END --name IF LEN(@sql_orderby) > 0 SET @sql_orderby = @sql_orderby + ', ' SET @sql_orderby = @sql_orderby + ' p.[Name] ASC' END SET @sql = @sql + ' ORDER BY' + @sql_orderby --PRINT (@sql) EXEC sp_executesql @sql DROP TABLE #FilteredCategoryIds 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 GROUP BY ProductId ORDER BY min([Id]) --total records SET @TotalRecords = @@rowcount DROP TABLE #DisplayOrderTmp --prepare filterable specification attribute option identifier (if requested) IF @LoadFilterableSpecificationAttributeOptionIds = 1 BEGIN CREATE TABLE #FilterableSpecs ( [SpecificationAttributeOptionId] int NOT NULL ) INSERT INTO #FilterableSpecs ([SpecificationAttributeOptionId]) SELECT DISTINCT [psam].SpecificationAttributeOptionId FROM [Product_SpecificationAttribute_Mapping] [psam] WHERE [psam].[AllowFiltering] = 1 AND [psam].[ProductId] IN (SELECT [pi].ProductId FROM #PageIndex [pi]) --build comma separated list of filterable identifiers SELECT @FilterableSpecificationAttributeOptionIds = COALESCE(@FilterableSpecificationAttributeOptionIds + ',' , '') + CAST(SpecificationAttributeOptionId as nvarchar(1000)) FROM #FilterableSpecs DROP TABLE #FilterableSpecs END --return products SELECT TOP (@RowsToReturn) p.* FROM #PageIndex [pi] INNER JOIN Product p on p.Id = [pi].[ProductId] WHERE [pi].IndexId > @PageLowerBound AND [pi].IndexId < @PageUpperBound ORDER BY [pi].IndexId DROP TABLE #PageIndex END GO IF EXISTS ( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[nop_getprimarykey_indexname]') AND [type] in (N'FN', N'IF', N'TF')) DROP FUNCTION [nop_getprimarykey_indexname] GO CREATE FUNCTION [dbo].[nop_getprimarykey_indexname] ( @table_name nvarchar(1000) = null ) RETURNS nvarchar(1000) AS BEGIN DECLARE @index_name nvarchar(1000) SELECT @index_name = i.name FROM sys.tables AS tbl INNER JOIN sys.indexes AS i ON (i.index_id > 0 and i.is_hypothetical = 0) AND (i.object_id=tbl.object_id) WHERE (i.is_unique=1 and i.is_disabled=0) and (tbl.name=@table_name) RETURN @index_name END GO IF EXISTS ( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[FullText_IsSupported]') AND OBJECTPROPERTY(object_id,N'IsProcedure') = 1) DROP PROCEDURE [FullText_IsSupported] GO CREATE PROCEDURE [FullText_IsSupported] AS BEGIN EXEC(' SELECT CASE SERVERPROPERTY(''IsFullTextInstalled'') WHEN 1 THEN CASE DatabaseProperty (DB_NAME(DB_ID()), ''IsFulltextEnabled'') WHEN 1 THEN 1 ELSE 0 END ELSE 0 END') END GO IF EXISTS ( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[FullText_Enable]') AND OBJECTPROPERTY(object_id,N'IsProcedure') = 1) DROP PROCEDURE [FullText_Enable] GO CREATE PROCEDURE [FullText_Enable] AS BEGIN --create catalog EXEC(' IF NOT EXISTS (SELECT 1 FROM sys.fulltext_catalogs WHERE [name] = ''nopCommerceFullTextCatalog'') CREATE FULLTEXT CATALOG [nopCommerceFullTextCatalog] AS DEFAULT') --create indexes DECLARE @create_index_text nvarchar(4000) SET @create_index_text = ' IF NOT EXISTS (SELECT 1 FROM sys.fulltext_indexes WHERE object_id = object_id(''[Product]'')) CREATE FULLTEXT INDEX ON [Product]([Name], [ShortDescription], [FullDescription]) KEY INDEX [' + dbo.[nop_getprimarykey_indexname] ('Product') + '] ON [nopCommerceFullTextCatalog] WITH CHANGE_TRACKING AUTO' EXEC(@create_index_text) SET @create_index_text = ' IF NOT EXISTS (SELECT 1 FROM sys.fulltext_indexes WHERE object_id = object_id(''[ProductVariant]'')) CREATE FULLTEXT INDEX ON [ProductVariant]([Name], [Description], [SKU]) KEY INDEX [' + dbo.[nop_getprimarykey_indexname] ('ProductVariant') + '] ON [nopCommerceFullTextCatalog] WITH CHANGE_TRACKING AUTO' EXEC(@create_index_text) SET @create_index_text = ' IF NOT EXISTS (SELECT 1 FROM sys.fulltext_indexes WHERE object_id = object_id(''[LocalizedProperty]'')) CREATE FULLTEXT INDEX ON [LocalizedProperty]([LocaleValue]) KEY INDEX [' + dbo.[nop_getprimarykey_indexname] ('LocalizedProperty') + '] ON [nopCommerceFullTextCatalog] WITH CHANGE_TRACKING AUTO' EXEC(@create_index_text) END GO IF EXISTS ( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[FullText_Disable]') AND OBJECTPROPERTY(object_id,N'IsProcedure') = 1) DROP PROCEDURE [FullText_Disable] GO CREATE PROCEDURE [FullText_Disable] AS BEGIN EXEC(' --drop indexes IF EXISTS (SELECT 1 FROM sys.fulltext_indexes WHERE object_id = object_id(''[Product]'')) DROP FULLTEXT INDEX ON [Product] ') EXEC(' IF EXISTS (SELECT 1 FROM sys.fulltext_indexes WHERE object_id = object_id(''[ProductVariant]'')) DROP FULLTEXT INDEX ON [ProductVariant] ') EXEC(' IF EXISTS (SELECT 1 FROM sys.fulltext_indexes WHERE object_id = object_id(''[LocalizedProperty]'')) DROP FULLTEXT INDEX ON [LocalizedProperty] ') --drop catalog EXEC(' IF EXISTS (SELECT 1 FROM sys.fulltext_catalogs WHERE [name] = ''nopCommerceFullTextCatalog'') DROP FULLTEXT CATALOG [nopCommerceFullTextCatalog] ') END GO --language pack import IF EXISTS ( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[LanguagePackImport]') AND OBJECTPROPERTY(object_id,N'IsProcedure') = 1) DROP PROCEDURE [LanguagePackImport] GO CREATE PROCEDURE [LanguagePackImport] ( @LanguageId int, @XmlPackage xml ) AS BEGIN IF EXISTS(SELECT * FROM [Language] WHERE [Id] = @LanguageId) BEGIN CREATE TABLE #LocaleStringResourceTmp ( [LanguageId] [int] NOT NULL, [ResourceName] [nvarchar](200) NOT NULL, [ResourceValue] [nvarchar](MAX) NOT NULL ) INSERT INTO #LocaleStringResourceTmp (LanguageID, ResourceName, ResourceValue) SELECT @LanguageId, nref.value('@Name', 'nvarchar(200)'), nref.value('Value[1]', 'nvarchar(MAX)') FROM @XmlPackage.nodes('//Language/LocaleResource') AS R(nref) DECLARE @ResourceName nvarchar(200) DECLARE @ResourceValue nvarchar(MAX) DECLARE cur_localeresource CURSOR FOR SELECT LanguageID, ResourceName, ResourceValue FROM #LocaleStringResourceTmp OPEN cur_localeresource FETCH NEXT FROM cur_localeresource INTO @LanguageId, @ResourceName, @ResourceValue WHILE @@FETCH_STATUS = 0 BEGIN IF (EXISTS (SELECT 1 FROM [LocaleStringResource] WHERE LanguageID=@LanguageId AND ResourceName=@ResourceName)) BEGIN UPDATE [LocaleStringResource] SET [ResourceValue]=@ResourceValue WHERE LanguageID=@LanguageId AND ResourceName=@ResourceName END ELSE BEGIN INSERT INTO [LocaleStringResource] ( [LanguageId], [ResourceName], [ResourceValue] ) VALUES ( @LanguageId, @ResourceName, @ResourceValue ) END FETCH NEXT FROM cur_localeresource INTO @LanguageId, @ResourceName, @ResourceValue END CLOSE cur_localeresource DEALLOCATE cur_localeresource DROP TABLE #LocaleStringResourceTmp END END GO --Add 'Weight' column to [Shipment] and [OrderProductVariant] tables IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[Shipment]') and NAME='TotalWeight') BEGIN ALTER TABLE [Shipment] ADD [TotalWeight] decimal(18, 4) NULL END GO IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[OrderProductVariant]') and NAME='ItemWeight') BEGIN ALTER TABLE [OrderProductVariant] ADD [ItemWeight] decimal(18, 4) NULL END GO --delete obsolete permission DELETE FROM [PermissionRecord] WHERE [SystemName] = N'ManagePromotionFeeds' GO DELETE FROM [Setting] WHERE [Name] = N'smssettings.activesmsprovidersystemnames' GO DELETE FROM [PermissionRecord] WHERE [SystemName] = N'ManageSMSProviders' GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'clickatellsettings.enabled') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'clickatellsettings.enabled', N'false') END GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'verizonsettings.enabled') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'verizonsettings.enabled', N'false') END GO --Add 'AllowGuestsToVote' column to [Poll] table IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[Poll]') and NAME='AllowGuestsToVote') BEGIN ALTER TABLE [Poll] ADD [AllowGuestsToVote] bit NULL END GO UPDATE [Poll] SET [AllowGuestsToVote] = 0 WHERE [AllowGuestsToVote] IS NULL GO ALTER TABLE [Poll] ALTER COLUMN [AllowGuestsToVote] bit NOT NULL GO --'Recurring payment cancelled' message template IF NOT EXISTS ( SELECT 1 FROM [MessageTemplate] WHERE [Name] = N'RecurringPaymentCancelled.StoreOwnerNotification') BEGIN INSERT [MessageTemplate] ([Name], [BccEmailAddresses], [Subject], [Body], [IsActive], [EmailAccountId]) VALUES (N'RecurringPaymentCancelled.StoreOwnerNotification', null, N'%Store.Name%. Recurring payment cancelled', N'

%Store.Name%

%Customer.FullName% (%Customer.Email%) has just cancelled a recurring payment ID=%RecurringPayment.ID%.

', 1, 0) END GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'catalogsettings.manufacturersblockitemstodisplay') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'catalogsettings.manufacturersblockitemstodisplay', N'5') END GO IF EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[Order]') and NAME='OrderWeight') BEGIN ALTER TABLE [Order] DROP COLUMN [OrderWeight] END GO --Add 'AllowedQuantities' column to [ProductVariant] table IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[ProductVariant]') and NAME='AllowedQuantities') BEGIN ALTER TABLE [ProductVariant] ADD [AllowedQuantities] nvarchar(1000) NULL END GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'mediasettings.autocompletesearchthumbpicturesize') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'mediasettings.autocompletesearchthumbpicturesize', N'20') END GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'catalogsettings.showproductimagesinsearchautocomplete') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'catalogsettings.showproductimagesinsearchautocomplete', N'false') END GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'frooglesettings.passshippinginfo') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'frooglesettings.passshippinginfo', N'false') END GO IF (EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[ShippingByWeight]') and OBJECTPROPERTY(object_id, N'IsUserTable') = 1)) AND (NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[ShippingByWeight]') and NAME='StateProvinceId')) BEGIN EXEC ('ALTER TABLE [ShippingByWeight] ADD [StateProvinceId] int NULL') END GO IF (EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[ShippingByWeight]') and OBJECTPROPERTY(object_id, N'IsUserTable') = 1)) AND (EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[ShippingByWeight]') and NAME='StateProvinceId')) BEGIN EXEC ('UPDATE [ShippingByWeight] SET [StateProvinceId] = 0 WHERE [StateProvinceId] IS NULL') END GO IF (EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[ShippingByWeight]') and OBJECTPROPERTY(object_id, N'IsUserTable') = 1)) AND (EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[ShippingByWeight]') and NAME='StateProvinceId')) BEGIN EXEC('ALTER TABLE [ShippingByWeight] ALTER COLUMN [StateProvinceId] int NOT NULL') END GO IF (EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[ShippingByWeight]') and OBJECTPROPERTY(object_id, N'IsUserTable') = 1)) AND (NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[ShippingByWeight]') and NAME='Zip')) BEGIN EXEC ('ALTER TABLE [ShippingByWeight] ADD [Zip] nvarchar(400) NULL') END GO IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'catalogsettings.fileuploadallowedextensions') BEGIN INSERT [Setting] ([Name], [Value]) VALUES (N'catalogsettings.fileuploadallowedextensions', N'') END GO --new activity types IF NOT EXISTS (SELECT 1 FROM [ActivityLogType] WHERE [SystemKeyword] = N'PublicStore.ViewCategory') BEGIN INSERT [ActivityLogType] ([SystemKeyword], [Name], [Enabled]) VALUES (N'PublicStore.ViewCategory', N'Public store. View a category', N'false') END GO IF NOT EXISTS (SELECT 1 FROM [ActivityLogType] WHERE [SystemKeyword] = N'PublicStore.ViewManufacturer') BEGIN INSERT [ActivityLogType] ([SystemKeyword], [Name], [Enabled]) VALUES (N'PublicStore.ViewManufacturer', N'Public store. View a manufacturer', N'false') END GO IF NOT EXISTS (SELECT 1 FROM [ActivityLogType] WHERE [SystemKeyword] = N'PublicStore.ViewProduct') BEGIN INSERT [ActivityLogType] ([SystemKeyword], [Name], [Enabled]) VALUES (N'PublicStore.ViewProduct', N'Public store. View a product', N'false') END GO IF NOT EXISTS (SELECT 1 FROM [ActivityLogType] WHERE [SystemKeyword] = N'PublicStore.PlaceOrder') BEGIN INSERT [ActivityLogType] ([SystemKeyword], [Name], [Enabled]) VALUES (N'PublicStore.PlaceOrder', N'Public store. Place an order', N'false') END GO