--upgrade scripts from nopCommerce 3.50 to 3.60 --new locale resources declare @resources xml --a resource will be deleted if its value is empty set @resources=' Notify customer about shipping from multiple locations Check if you want customers to be notified when shipping from multiple locations. Please note that your order will be shipped from multiple locations Edit page Prices consider promotions Check if you want prices to be calculated with promotions (tier prices, discounts, special prices, tax, etc). But please note that it can significantly reduce time required to generate the feed file. Check if it''s telecommunications, broadcasting and electronic services. It''s used for tax calculation in Europe Union. Allow customers to contact vendors Check to allow customers to contact vendors. Contact Vendor - {0} Contact vendor Submit Your email Enter your email address Enter email {0}. Contact us Enquiry Enter your enquiry Enter enquiry Your name Enter your name Enter your name Your enquiry has been successfully sent to the vendor. Topic templates Display order Name Name is required View path View path is required Topic template Choose a topic template. This template defines how this topic will be displayed. When an attribute is required, the customer must choose an appropriate attribute value before they can continue. Test template back to template Send Send email to Send test email to ensure that everything is properly configured. Email has been successfully queued. Tokens Please enter tokens you want to be replaced below Enter tokens. Send test email Search page. Page size options (comma separated) Export to Excel (all found) Export to XML (all found) Print packaging slips (all found) Warehouse If an asterisk is selected, then this shipping rate will apply to all warehouses. Custom goods (no identifier exists) Low High Maximum discount amount Maximum allowed discount amount. Leave empty to allow any discount amount. If you''re using "Assigned to products" discount type, then it''s applied to each product separately. Default image quality (0 - 100) The image quality to be used for uploaded images. Once changed you have to manually delete already generated thumbs. PDF settings Enable XSRF protection for admin area Check to enable XSRF protection for admin area. Profit Profit of this order. Include tax Check to include tax when generating tracking code for {ECOMMERCE} part. Pass shipping info (weight) Check if you want to include shipping information (weight) in generated XML file. Pass shipping info (dimensions) Check if you want to include shipping information (dimensions) in generated XML file. Subscribe Unsubscribe A verification email has been sent. Thank you! Newsletter box. Allow to unsubscribe Check if you want to allow customers to display "unsubscribe" option in the newsletter block. General Performance Product reviews Search Compare products Sharing Enable XSRF protection for public store Check to enable XSRF protection for public store. Search term minimum length Specify minimum length of search term. Published Search by a "Published" property. All Published only Unpublished only Coupon code Search by discount coupon code. Discount type Search by discount type. Payment error: {0} Enable honeypot Check to enable honeypot technique for registration page. Friendly URL name A friendly name for generated affiliate URL (by default affiliate ID is used). It''s more friendly for marketing purposes. Leave empty to use affiliate identifier. Remove affiliate Friendly URL name Search by a friendly URL name. First name Search by a first name. Last name Search by a last name. Load only with orders Check to load affiliates only with orders placed (by affiliated customers). Orders start date The start date for the order search. Orders end date The end date for the order search. Search by a specific order status e.g. Complete. Search by a specific payment status e.g. Paid. Search by a specific shipping status e.g. Not yet shipped. End date The end date for the search. Start date The start date for the search. Include in footer (column 1) Check to include this topic in the footer (column 1). Ensure that your theme supports it. Include in footer (column 2) Check to include this topic in the footer (column 2). Ensure that your theme supports it. Include in footer (column 3) Check to include this topic in the footer (column 3). Ensure that your theme supports it. Accessible when store closed Check to allow customer to view this topic details page when the store is closed. Order notes Search in order notes. Leave empty to load all orders. Send welcome message Welcome email has been successfully sent. Password minimum length Specify password minimum length. Alt Override "alt" attribute for "img" HTML element. If empty, then a default rule will be used (e.g. product name). Title Override "title" attribute for "img" HTML element. If empty, then a default rule will be used (e.g. product name). Used by products Here you can see a list of products which use this attribute. Product Published Info Predefined values Add a new value Edit value Cost The attribute value cost is the cost of all the different components which make up this value. This may be either the purchase price if the components are bought from outside suppliers, or the combined cost of materials and manufacturing processes if the component is made in-house. Display order The display order of the attribute value. 1 represents the first item in attribute value list. Is pre-selected Determines whether this attribute value is pre selected for the customer Name The attribute value name e.g. ''Blue'' for Color attributes. Please provide a name. Price adjustment The price adjustment applied when choosing this attribute value e.g. ''10'' to add 10 dollars. Weight adjustment The weight adjustment applied when choosing this attribute value Predefined (default) values are helpful for a store owner when creating new products. Then when you add the attribute to a product, you don''t have to create the values again. You need to save the product attribute before you can add values for this page. View/Edit values Total: Applied to products You need to save the discount before you can add products for this discount page. Product Add a new product Applied to categories You need to save the discount before you can add categories for this discount page. Category Add a new category Active Search by a specific status e.g. Active. All Active Not active All Activated Deactivated Discount name Search by discount name. Entered quantity. Picture Order total Order ID Re-send activation message Activation email has been successfully sent. Times used Contact us page. Use system email Check to use your system email as "From" field when sending emails from contact us page. Otherwise, customer email will be used (please note that some email services do not allow it). Active discussions page size Set the page size for active discussions page e.g. ''10'' results per page. Password recovery link. Days valid Enter number of days for password recovery link. Set to 0 if it doesn''t expire.. Your password recovery link is expired Wrong password recovery token Download license Image General Please enter username Name Add to compare list The system keyword for this poll. For example, you can enter ''LeftColumnPoll'' in order to display it in the left column. Enter your email here... Body overview Brief overview of blog post. If specified, then it will be used instead of full body on the main blog page. HTML is supported. details Print PDF invoices (all found) ''Date of Birth'' required Check if ''Date of Birth'' is required. Check if ''Date of Birth'' is required. Date of birth is required Contact us page. ''Subject'' field Check to allow a customer to type a subject on the contact us page. Subject Enter subject Please enter subject Subject Enter subject Please enter subject Disable PDF invoices for pending orders If checked, customers won''t be allowed to print PDF invoices for pending orders. {0} [{1}] {0} [{1}] Payment method Search by a specific payment method. Loading... Close (Esc) Previous (Left arrow key) Next (Right arrow key) %curr% of %total% Discounts No discounts available. Create at least one discount before mapping. Assigned to manufacturers Applied to manufacturers You need to save the discount before you can add manufacturers for this discount page. Manufacturer Add a new manufacturer Customer roles Search by a specific customer role. Return Action: Date Requested: Return Reason: View News Archive Gift Card ({0}) Search keyword: PAngV (base price) enabled Check to display baseprice of a product. This is required according to the German law (PAngV). If you sell 500ml of beer for 1,50 euro, then you have to display baseprice: 3.00 euro per 1L. Amount in product Enter an amount in product Unit of product Enter a unit of product. Reference amount Enter a reference amount Reference unit Enter a reference unit. equates to {0} per {1} {2} Home View the sitemap for this website below, with links to each of the pages and brief descriptions of what to find in each section Send In order to use this functionality you have to disable the following setting: Configuration > Catalog settings > Perfomance > Ignore "limit per store" rules (sitewide). In order to use this functionality you have to disable the following setting: Configuration > Catalog settings > Perfomance > Ignore ACL rules (sitewide). Display order The topic display order. 1 represents the first item in the list. It''s used with properties such as "Include in top menu" or "Include in footer". You have reached maximum number of downloads {0} Billing country Filter by order billing country. The product has been added to your product comparison product comparison]]> ' 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'shippingsettings.notifycustomeraboutshippingfrommultiplelocations') BEGIN INSERT [Setting] ([Name], [Value], [StoreId]) VALUES (N'shippingsettings.notifycustomeraboutshippingfrommultiplelocations', N'false', 0) END GO --new setting IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'frooglesettings.pricesconsiderpromotions') BEGIN INSERT [Setting] ([Name], [Value], [StoreId]) VALUES (N'frooglesettings.pricesconsiderpromotions', N'false', 0) END GO --new setting IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'vendorsettings.allowcustomerstocontactvendors') BEGIN INSERT [Setting] ([Name], [Value], [StoreId]) VALUES (N'vendorsettings.allowcustomerstocontactvendors', N'true', 0) END GO --new setting IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'externalauthenticationsettings.requireemailvalidation') BEGIN INSERT [Setting] ([Name], [Value], [StoreId]) VALUES (N'externalauthenticationsettings.requireemailvalidation', N'false', 0) END GO --Topic templates IF NOT EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TopicTemplate]') and OBJECTPROPERTY(object_id, N'IsUserTable') = 1) BEGIN CREATE TABLE [dbo].[TopicTemplate]( [Id] [int] IDENTITY(1,1) NOT NULL, [Name] [nvarchar](400) NOT NULL, [ViewPath] [nvarchar](400) NOT NULL, [DisplayOrder] [int] 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].[TopicTemplate] WHERE [Name] = N'Default template') BEGIN INSERT [dbo].[TopicTemplate] ([Name], [ViewPath], [DisplayOrder]) VALUES (N'Default template', N'TopicDetails', 1) END GO --new column IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[Topic]') and NAME='TopicTemplateId') BEGIN ALTER TABLE [Topic] ADD [TopicTemplateId] int NULL END GO UPDATE [Topic] SET [TopicTemplateId] = 1 WHERE [TopicTemplateId] IS NULL GO ALTER TABLE [Topic] ALTER COLUMN [TopicTemplateId] int NOT NULL GO --new setting IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'frooglesettings.expirationnumberofdays') BEGIN INSERT [Setting] ([Name], [Value], [StoreId]) VALUES (N'frooglesettings.expirationnumberofdays', N'28', 0) END GO --shipping by weight plugin IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[ShippingByWeight]') and OBJECTPROPERTY(object_id, N'IsUserTable') = 1) BEGIN --new [StoreId] column EXEC ('IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id(''[ShippingByWeight]'') and NAME=''WarehouseId'') BEGIN ALTER TABLE [ShippingByWeight] ADD [WarehouseId] int NULL exec(''UPDATE [ShippingByWeight] SET [WarehouseId] = 0'') EXEC (''ALTER TABLE [ShippingByWeight] ALTER COLUMN [WarehouseId] int NOT NULL'') END') END GO --froogle plugin IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[GoogleProduct]') and OBJECTPROPERTY(object_id, N'IsUserTable') = 1) BEGIN --new [StoreId] column EXEC ('IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id(''[GoogleProduct]'') and NAME=''CustomGoods'') BEGIN ALTER TABLE [GoogleProduct] ADD [CustomGoods] bit NULL exec(''UPDATE [GoogleProduct] SET [CustomGoods] = 0'') EXEC (''ALTER TABLE [GoogleProduct] ALTER COLUMN [CustomGoods] bit NOT NULL'') END') END GO --delete setting DELETE FROM [Setting] WHERE [name] = N'catalogsettings.topcategorymenusubcategorylevelstodisplay' GO --queued email priority IF EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[QueuedEmail]') and NAME='Priority') BEGIN EXEC sp_rename 'QueuedEmail.Priority', 'PriorityId', 'COLUMN'; EXEC ('UPDATE [QueuedEmail] SET [PriorityId] = 0 WHERE [PriorityId] <> 5') END GO --new column IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[Discount]') and NAME='MaximumDiscountAmount') BEGIN ALTER TABLE [Discount] ADD [MaximumDiscountAmount] decimal(18,4) NULL END GO --more indexes IF NOT EXISTS (SELECT 1 from sys.indexes WHERE [NAME]=N'IX_Product_ProductAttribute_Mapping_ProductId_DisplayOrder' and object_id=object_id(N'[Product_ProductAttribute_Mapping]')) BEGIN CREATE NONCLUSTERED INDEX [IX_Product_ProductAttribute_Mapping_ProductId_DisplayOrder] ON [Product_ProductAttribute_Mapping] ([ProductId] ASC, [DisplayOrder] ASC) END GO IF EXISTS (SELECT 1 from sys.indexes WHERE [NAME]=N'IX_Product_ProductAttribute_Mapping_ProductId' and object_id=object_id(N'[Product_ProductAttribute_Mapping]')) BEGIN DROP INDEX [IX_Product_ProductAttribute_Mapping_ProductId] ON [Product_ProductAttribute_Mapping] END GO --more indexes IF NOT EXISTS (SELECT 1 from sys.indexes WHERE [NAME]=N'IX_ProductAttributeValue_ProductAttributeMappingId_DisplayOrder' and object_id=object_id(N'[ProductAttributeValue]')) BEGIN CREATE NONCLUSTERED INDEX [IX_ProductAttributeValue_ProductAttributeMappingId_DisplayOrder] ON [ProductAttributeValue] ([ProductAttributeMappingId] ASC, [DisplayOrder] ASC) END GO IF EXISTS (SELECT 1 from sys.indexes WHERE [NAME]=N'IX_ProductAttributeValue_ProductAttributeMappingId' and object_id=object_id(N'[ProductAttributeValue]')) BEGIN DROP INDEX [IX_ProductAttributeValue_ProductAttributeMappingId] ON [ProductAttributeValue] END GO --new setting IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'securitysettings.enablexsrfprotectionforadminarea') BEGIN INSERT [Setting] ([Name], [Value], [StoreId]) VALUES (N'securitysettings.enablexsrfprotectionforadminarea', N'true', 0) END GO --rename setting UPDATE [Setting] SET [Name] = N'frooglesettings.passshippinginfoweight' WHERE [Name] = N'frooglesettings.passshippinginfo' GO --new setting IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'frooglesettings.passshippinginfodimensions') BEGIN INSERT [Setting] ([Name], [Value], [StoreId]) VALUES (N'frooglesettings.passshippinginfodimensions', N'false', 0) END GO --new setting IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'customersettings.newsletterblockallowtounsubscribe') BEGIN INSERT [Setting] ([Name], [Value], [StoreId]) VALUES (N'customersettings.newsletterblockallowtounsubscribe', N'false', 0) END GO --'Newsletter unsubscribe' message template IF NOT EXISTS ( SELECT 1 FROM [MessageTemplate] WHERE [Name] = N'NewsLetterSubscription.DeactivationMessage') BEGIN INSERT [MessageTemplate] ([Name], [BccEmailAddresses], [Subject], [Body], [IsActive], [EmailAccountId], [LimitedToStores], [AttachedDownloadId]) VALUES (N'NewsLetterSubscription.DeactivationMessage', null, N'%Store.Name%. Subscription deactivation message.', N'

Click here to unsubscribe from our newsletter.

If you received this email by mistake, simply delete it.

', 1, 0, 0, 0) END GO --new setting IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'securitysettings.enablexsrfprotectionforpublicstore') BEGIN INSERT [Setting] ([Name], [Value], [StoreId]) VALUES (N'securitysettings.enablexsrfprotectionforpublicstore', N'true', 0) END GO --Delete setting DELETE FROM [Setting] WHERE Name = N'storeinformationsettings.responsivedesignsupported' 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 [dbo].[ProductLoadAllPaged] ( @CategoryIds nvarchar(MAX) = null, --a list of category IDs (comma-separated list). e.g. 1,2,3 @ManufacturerId int = 0, @StoreId int = 0, @VendorId int = 0, @WarehouseId int = 0, @ProductTypeId int = null, --product type identifier, null - load all products @VisibleIndividuallyOnly bit = 0, --0 - load all products , 1 - "visible indivially" only @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, --a value indicating whether to search by a specified "keyword" in product descriptions @SearchSku bit = 0, --a value indicating whether to search by a specified "keyword" in product SKU @SearchProductTags bit = 0, --a value indicating whether to search by a specified "keyword" in product tags @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 @AllowedCustomerRoleIds nvarchar(MAX) = null, --a list of customer role IDs (comma-separated list) for which a product should be shown (if a subjet to ACL) @PageIndex int = 0, @PageSize int = 2147483644, @ShowHidden bit = 0, @OverridePublished bit = null, --null - process "Published" property according to "showHidden" parameter, true - load only "Published" products, false - load only "Unpublished" products @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 --remove wrong chars (' ") SET @Keywords = REPLACE(@Keywords, '''', '') SET @Keywords = REPLACE(@Keywords, '"', '') --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 --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 ' --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 ' IF @SearchDescriptions = 1 BEGIN --product short description 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 ' --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 --SKU IF @SearchSku = 1 BEGIN SET @sql = @sql + ' UNION SELECT p.Id FROM Product p with (NOLOCK) WHERE ' IF @UseFullTextSearch = 1 SET @sql = @sql + 'CONTAINS(p.[Sku], @Keywords) ' ELSE SET @sql = @sql + 'PATINDEX(@Keywords, p.[Sku]) > 0 ' END IF @SearchProductTags = 1 BEGIN --product tag SET @sql = @sql + ' UNION SELECT pptm.Product_Id FROM Product_ProductTag_Mapping pptm with(NOLOCK) INNER JOIN ProductTag pt with(NOLOCK) ON pt.Id = pptm.ProductTag_Id WHERE ' IF @UseFullTextSearch = 1 SET @sql = @sql + 'CONTAINS(pt.[Name], @Keywords) ' ELSE SET @sql = @sql + 'PATINDEX(@Keywords, pt.[Name]) > 0 ' --localized product tag SET @sql = @sql + ' UNION SELECT pptm.Product_Id FROM LocalizedProperty lp with (NOLOCK) INNER JOIN Product_ProductTag_Mapping pptm with(NOLOCK) ON lp.EntityId = pptm.ProductTag_Id WHERE lp.LocaleKeyGroup = N''ProductTag'' 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 ' 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) --filter by customer role IDs (access control list) SET @AllowedCustomerRoleIds = isnull(@AllowedCustomerRoleIds, '') CREATE TABLE #FilteredCustomerRoleIds ( CustomerRoleId int not null ) INSERT INTO #FilteredCustomerRoleIds (CustomerRoleId) SELECT CAST(data as int) FROM [nop_splitstring_to_table](@AllowedCustomerRoleIds, ',') --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 --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 vendor IF @VendorId > 0 BEGIN SET @sql = @sql + ' AND p.VendorId = ' + CAST(@VendorId AS nvarchar(max)) END --filter by warehouse IF @WarehouseId > 0 BEGIN --we should also ensure that 'ManageInventoryMethodId' is set to 'ManageStock' (1) --but we skip it in order to prevent hard-coded values (e.g. 1) and for better performance SET @sql = @sql + ' AND ( (p.UseMultipleWarehouses = 0 AND p.WarehouseId = ' + CAST(@WarehouseId AS nvarchar(max)) + ') OR (p.UseMultipleWarehouses > 0 AND EXISTS (SELECT 1 FROM ProductWarehouseInventory [pwi] WHERE [pwi].WarehouseId = ' + CAST(@WarehouseId AS nvarchar(max)) + ' AND [pwi].ProductId = p.Id)) )' END --filter by product type IF @ProductTypeId is not null BEGIN SET @sql = @sql + ' AND p.ProductTypeId = ' + CAST(@ProductTypeId AS nvarchar(max)) END --filter by parent product identifer IF @VisibleIndividuallyOnly = 1 BEGIN SET @sql = @sql + ' AND p.VisibleIndividually = 1' END --filter by product tag IF ISNULL(@ProductTagId, 0) != 0 BEGIN SET @sql = @sql + ' AND pptm.ProductTag_Id = ' + CAST(@ProductTagId AS nvarchar(max)) END --"Published" property IF (@OverridePublished is null) BEGIN --process according to "showHidden" IF @ShowHidden = 0 BEGIN SET @sql = @sql + ' AND p.Published = 1' END END ELSE IF (@OverridePublished = 1) BEGIN --published only SET @sql = @sql + ' AND p.Published = 1' END ELSE IF (@OverridePublished = 0) BEGIN --unpublished only SET @sql = @sql + ' AND p.Published = 0' END --show hidden IF @ShowHidden = 0 BEGIN SET @sql = @sql + ' AND p.Deleted = 0 AND (getutcdate() BETWEEN ISNULL(p.AvailableStartDateTimeUtc, ''1/1/1900'') and ISNULL(p.AvailableEndDateTimeUtc, ''1/1/2999''))' END --min price IF @PriceMin is not null BEGIN SET @sql = @sql + ' AND ( ( --special price (specified price and valid date range) (p.SpecialPrice IS NOT NULL AND (getutcdate() BETWEEN isnull(p.SpecialPriceStartDateTimeUtc, ''1/1/1900'') AND isnull(p.SpecialPriceEndDateTimeUtc, ''1/1/2999''))) AND (p.SpecialPrice >= ' + CAST(@PriceMin AS nvarchar(max)) + ') ) OR ( --regular price (price isnt specified or date range isnt valid) (p.SpecialPrice IS NULL OR (getutcdate() NOT BETWEEN isnull(p.SpecialPriceStartDateTimeUtc, ''1/1/1900'') AND isnull(p.SpecialPriceEndDateTimeUtc, ''1/1/2999''))) AND (p.Price >= ' + CAST(@PriceMin AS nvarchar(max)) + ') ) )' END --max price IF @PriceMax is not null BEGIN SET @sql = @sql + ' AND ( ( --special price (specified price and valid date range) (p.SpecialPrice IS NOT NULL AND (getutcdate() BETWEEN isnull(p.SpecialPriceStartDateTimeUtc, ''1/1/1900'') AND isnull(p.SpecialPriceEndDateTimeUtc, ''1/1/2999''))) AND (p.SpecialPrice <= ' + CAST(@PriceMax AS nvarchar(max)) + ') ) OR ( --regular price (price isnt specified or date range isnt valid) (p.SpecialPrice IS NULL OR (getutcdate() NOT BETWEEN isnull(p.SpecialPriceStartDateTimeUtc, ''1/1/1900'') AND isnull(p.SpecialPriceEndDateTimeUtc, ''1/1/2999''))) AND (p.Price <= ' + CAST(@PriceMax AS nvarchar(max)) + ') ) )' END --show hidden and ACL IF @ShowHidden = 0 BEGIN SET @sql = @sql + ' AND (p.SubjectToAcl = 0 OR EXISTS ( SELECT 1 FROM #FilteredCustomerRoleIds [fcr] WHERE [fcr].CustomerRoleId IN ( SELECT [acl].CustomerRoleId FROM [AclRecord] acl with (NOLOCK) WHERE [acl].EntityId = p.Id AND [acl].EntityName = ''Product'' ) ))' END --show hidden and filter by store IF @StoreId > 0 BEGIN SET @sql = @sql + ' AND (p.LimitedToStores = 0 OR EXISTS ( SELECT 1 FROM [StoreMapping] sm with (NOLOCK) WHERE [sm].EntityId = p.Id AND [sm].EntityName = ''Product'' and [sm].StoreId=' + CAST(@StoreId 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 with (NOLOCK) 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 = ' p.[Price] ASC' ELSE IF @OrderBy = 11 /* Price: High to Low */ SET @sql_orderby = ' p.[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 DROP TABLE #FilteredCustomerRoleIds DROP TABLE #KeywordProducts 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] with (NOLOCK) 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(4000)) FROM #FilterableSpecs DROP TABLE #FilterableSpecs END --return products SELECT TOP (@RowsToReturn) p.* FROM #PageIndex [pi] INNER JOIN Product p with (NOLOCK) on p.Id = [pi].[ProductId] WHERE [pi].IndexId > @PageLowerBound AND [pi].IndexId < @PageUpperBound ORDER BY [pi].IndexId DROP TABLE #PageIndex END GO --new setting IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'securitysettings.honeypotenabled') BEGIN INSERT [Setting] ([Name], [Value], [StoreId]) VALUES (N'securitysettings.honeypotenabled', N'false', 0) END GO --new setting IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'securitysettings.honeypotinputname') BEGIN INSERT [Setting] ([Name], [Value], [StoreId]) VALUES (N'securitysettings.honeypotinputname', N'hpinput', 0) END GO --new column IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[Affiliate]') and NAME='FriendlyUrlName') BEGIN ALTER TABLE [Affiliate] ADD [FriendlyUrlName] nvarchar(MAX) NULL END GO --new column IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[Topic]') and NAME='IncludeInFooterColumn1') BEGIN ALTER TABLE [Topic] ADD [IncludeInFooterColumn1] bit NULL END GO UPDATE [Topic] SET [IncludeInFooterColumn1] = 0 WHERE [IncludeInFooterColumn1] IS NULL GO ALTER TABLE [Topic] ALTER COLUMN [IncludeInFooterColumn1] bit NOT NULL GO --new column IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[Topic]') and NAME='IncludeInFooterColumn2') BEGIN ALTER TABLE [Topic] ADD [IncludeInFooterColumn2] bit NULL END GO UPDATE [Topic] SET [IncludeInFooterColumn2] = 0 WHERE [IncludeInFooterColumn2] IS NULL GO ALTER TABLE [Topic] ALTER COLUMN [IncludeInFooterColumn2] bit NOT NULL GO --new column IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[Topic]') and NAME='IncludeInFooterColumn3') BEGIN ALTER TABLE [Topic] ADD [IncludeInFooterColumn3] bit NULL END GO UPDATE [Topic] SET [IncludeInFooterColumn3] = 0 WHERE [IncludeInFooterColumn3] IS NULL GO ALTER TABLE [Topic] ALTER COLUMN [IncludeInFooterColumn3] bit NOT NULL GO --rename setting UPDATE [Setting] SET [Name] = N'forumsettings.activediscussionspagesize' WHERE [Name] = N'forumsettings.activediscussionspagetopiccount' GO --delete setting DELETE [Setting] WHERE [Name] = N'forumsettings.topicpostspagelinkdisplaycount' GO --new column IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[Topic]') and NAME='AccessibleWhenStoreClosed') BEGIN ALTER TABLE [Topic] ADD [AccessibleWhenStoreClosed] bit NULL END GO UPDATE [Topic] SET [AccessibleWhenStoreClosed] = 0 WHERE [AccessibleWhenStoreClosed] IS NULL GO ALTER TABLE [Topic] ALTER COLUMN [AccessibleWhenStoreClosed] bit NOT NULL GO --delete setting DELETE FROM [Setting] WHERE [name] = N'adminareasettings.displayproductpictures' GO --new column IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[Picture]') and NAME='TitleAttribute') BEGIN ALTER TABLE [Picture] ADD [TitleAttribute] nvarchar(MAX) NULL END GO --new column IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[Picture]') and NAME='AltAttribute') BEGIN ALTER TABLE [Picture] ADD [AltAttribute] nvarchar(MAX) NULL END GO --New table IF NOT EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PredefinedProductAttributeValue]') and OBJECTPROPERTY(object_id, N'IsUserTable') = 1) BEGIN CREATE TABLE [dbo].[PredefinedProductAttributeValue]( [Id] [int] IDENTITY(1,1) NOT NULL, [ProductAttributeId] [int] NOT NULL, [Name] [nvarchar](400) NOT NULL, [PriceAdjustment] [decimal](18,4) NOT NULL, [WeightAdjustment] [decimal](18,4) NOT NULL, [Cost] [decimal](18,4) NOT NULL, [IsPreSelected] [bit] NOT NULL, [DisplayOrder] [int] 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 = 'PredefinedProductAttributeValue_ProductAttribute' AND parent_object_id = Object_id('PredefinedProductAttributeValue') AND Objectproperty(object_id,N'IsForeignKey') = 1) ALTER TABLE dbo.PredefinedProductAttributeValue DROP CONSTRAINT PredefinedProductAttributeValue_ProductAttribute GO ALTER TABLE [dbo].[PredefinedProductAttributeValue] WITH CHECK ADD CONSTRAINT [PredefinedProductAttributeValue_ProductAttribute] FOREIGN KEY([ProductAttributeId]) REFERENCES [dbo].[ProductAttribute] ([Id]) ON DELETE CASCADE GO --rename some properties in attributes (XML) UPDATE [ShoppingCartItem] SET AttributesXml = REPLACE(AttributesXml, 'ProductVariantAttribute', 'ProductAttribute') GO UPDATE [OrderItem] SET AttributesXml = REPLACE(AttributesXml, 'ProductVariantAttribute', 'ProductAttribute') GO UPDATE [ProductAttributeCombination] SET AttributesXml = REPLACE(AttributesXml, 'ProductVariantAttribute', 'ProductAttribute') GO --more SQL indexes ALTER TABLE [Customer] ALTER COLUMN [SystemName] nvarchar(400) NULL GO IF NOT EXISTS (SELECT 1 from sys.indexes WHERE [NAME]=N'IX_Customer_SystemName' and object_id=object_id(N'[Customer]')) BEGIN CREATE NONCLUSTERED INDEX [IX_Customer_SystemName] ON [Customer] ([SystemName] ASC) END GO --new setting IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'customersettings.passwordrecoverylinkdaysvalid') BEGIN INSERT [Setting] ([Name], [Value], [StoreId]) VALUES (N'customersettings.passwordrecoverylinkdaysvalid', N'7', 0) END GO DELETE FROM [Setting] WHERE [name] = N'mediasettings.productthumbperrowonproductdetailspage' GO --new column IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[BlogPost]') and NAME='BodyOverview') BEGIN ALTER TABLE [BlogPost] ADD [BodyOverview] nvarchar(MAX) NULL END GO --new setting IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'customersettings.dateofbirthrequired') BEGIN INSERT [Setting] ([Name], [Value], [StoreId]) VALUES (N'customersettings.dateofbirthrequired', N'false', 0) END GO --new setting IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'commonsettings.subjectfieldoncontactusform') BEGIN INSERT [Setting] ([Name], [Value], [StoreId]) VALUES (N'commonsettings.subjectfieldoncontactusform', N'false', 0) END GO --new setting IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'pdfsettings.disablepdfinvoicesforpendingorders') BEGIN INSERT [Setting] ([Name], [Value], [StoreId]) VALUES (N'pdfsettings.disablepdfinvoicesforpendingorders', N'false', 0) END GO --new column IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[Manufacturer]') and NAME='HasDiscountsApplied') BEGIN ALTER TABLE [Manufacturer] ADD [HasDiscountsApplied] bit NULL END GO UPDATE [Manufacturer] SET [HasDiscountsApplied] = 0 WHERE [HasDiscountsApplied] IS NULL GO ALTER TABLE [Manufacturer] ALTER COLUMN [HasDiscountsApplied] bit NOT NULL GO --New table IF NOT EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Discount_AppliedToManufacturers]') and OBJECTPROPERTY(object_id, N'IsUserTable') = 1) BEGIN CREATE TABLE [dbo].[Discount_AppliedToManufacturers]( [Discount_Id] [int] NOT NULL, [Manufacturer_Id] [int] NOT NULL, PRIMARY KEY CLUSTERED ( [Discount_Id] ASC, [Manufacturer_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 = 'Discount_AppliedToManufacturers_Source' AND parent_object_id = Object_id('Discount_AppliedToManufacturers') AND Objectproperty(object_id,N'IsForeignKey') = 1) ALTER TABLE dbo.Discount_AppliedToManufacturers DROP CONSTRAINT Discount_AppliedToManufacturers_Source GO ALTER TABLE [dbo].[Discount_AppliedToManufacturers] WITH CHECK ADD CONSTRAINT [Discount_AppliedToManufacturers_Source] FOREIGN KEY([Discount_Id]) REFERENCES [dbo].[Discount] ([Id]) ON DELETE CASCADE GO IF EXISTS (SELECT 1 FROM sys.objects WHERE name = 'Discount_AppliedToManufacturers_Target' AND parent_object_id = Object_id('Discount_AppliedToManufacturers') AND Objectproperty(object_id,N'IsForeignKey') = 1) ALTER TABLE dbo.Discount_AppliedToManufacturers DROP CONSTRAINT Discount_AppliedToManufacturers_Target GO ALTER TABLE [dbo].[Discount_AppliedToManufacturers] WITH CHECK ADD CONSTRAINT [Discount_AppliedToManufacturers_Target] FOREIGN KEY([Manufacturer_Id]) REFERENCES [dbo].[Manufacturer] ([Id]) ON DELETE CASCADE GO --'Order refunded' message template IF NOT EXISTS ( SELECT 1 FROM [MessageTemplate] WHERE [Name] = N'OrderRefunded.CustomerNotification') BEGIN INSERT [MessageTemplate] ([Name], [BccEmailAddresses], [Subject], [Body], [IsActive], [EmailAccountId], [LimitedToStores], [AttachedDownloadId]) VALUES (N'OrderRefunded.CustomerNotification', null, N'%Store.Name%. Order #%Order.OrderNumber% refunded', N'

%Store.Name%

Hello %Order.CustomerFullName%,
Thanks for buying from %Store.Name%. Order #%Order.OrderNumber% has been has been refunded. Please allow 7-14 days for the refund to be reflected in your account.

Amount refunded: %Order.AmountRefunded%

Below is the summary of the order.

Order Number: %Order.OrderNumber%
Order Details: %Order.OrderURLForCustomer%
Date Ordered: %Order.CreatedOn%



Billing Address
%Order.BillingFirstName% %Order.BillingLastName%
%Order.BillingAddress1%
%Order.BillingCity% %Order.BillingZipPostalCode%
%Order.BillingStateProvince% %Order.BillingCountry%



Shipping Address
%Order.ShippingFirstName% %Order.ShippingLastName%
%Order.ShippingAddress1%
%Order.ShippingCity% %Order.ShippingZipPostalCode%
%Order.ShippingStateProvince% %Order.ShippingCountry%

Shipping Method: %Order.ShippingMethod%

%Order.Product(s)%

', 0, 0, 0, 0) END GO --new column IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[Product]') and NAME='BasepriceEnabled') BEGIN ALTER TABLE [Product] ADD [BasepriceEnabled] bit NULL END GO UPDATE [Product] SET [BasepriceEnabled] = 0 WHERE [BasepriceEnabled] IS NULL GO ALTER TABLE [Product] ALTER COLUMN [BasepriceEnabled] bit NOT NULL GO --new column IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[Product]') and NAME='BasepriceAmount') BEGIN ALTER TABLE [Product] ADD [BasepriceAmount] decimal(18,4) NULL END GO UPDATE [Product] SET [BasepriceAmount] = 0 WHERE [BasepriceAmount] IS NULL GO ALTER TABLE [Product] ALTER COLUMN [BasepriceAmount] decimal(18,4) NOT NULL GO --new column IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[Product]') and NAME='BasepriceUnitId') BEGIN ALTER TABLE [Product] ADD [BasepriceUnitId] int NULL END GO UPDATE [Product] SET [BasepriceUnitId] = 0 WHERE [BasepriceUnitId] IS NULL GO ALTER TABLE [Product] ALTER COLUMN [BasepriceUnitId] int NOT NULL GO --new column IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[Product]') and NAME='BasepriceBaseAmount') BEGIN ALTER TABLE [Product] ADD [BasepriceBaseAmount] decimal(18,4) NULL END GO UPDATE [Product] SET [BasepriceBaseAmount] = 0 WHERE [BasepriceBaseAmount] IS NULL GO ALTER TABLE [Product] ALTER COLUMN [BasepriceBaseAmount] decimal(18,4) NOT NULL GO --new column IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[Product]') and NAME='BasepriceBaseUnitId') BEGIN ALTER TABLE [Product] ADD [BasepriceBaseUnitId] int NULL END GO UPDATE [Product] SET [BasepriceBaseUnitId] = 0 WHERE [BasepriceBaseUnitId] IS NULL GO ALTER TABLE [Product] ALTER COLUMN [BasepriceBaseUnitId] int NOT NULL GO --new setting IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'catalogsettings.defaultcategorypagesize') BEGIN INSERT [Setting] ([Name], [Value], [StoreId]) VALUES (N'catalogsettings.defaultcategorypagesize', N'6', 0) END GO --new setting IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'catalogsettings.defaultmanufacturerpagesize') BEGIN INSERT [Setting] ([Name], [Value], [StoreId]) VALUES (N'catalogsettings.defaultmanufacturerpagesize', N'6', 0) END GO --new column IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE object_id=object_id('[Topic]') and NAME='DisplayOrder') BEGIN ALTER TABLE [Topic] ADD [DisplayOrder] int NULL END GO UPDATE [Topic] SET [DisplayOrder] = 1 WHERE [DisplayOrder] IS NULL GO ALTER TABLE [Topic] ALTER COLUMN [DisplayOrder] int NOT NULL GO --update DefaultClean theme settings. You should remove this code if you're going to use the old theme IF EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'storeinformationsettings.defaultstoretheme' and [Value] = N'DefaultClean') BEGIN UPDATE [Setting] SET [Value] = N'120' WHERE [Name] = 'mediasettings.avatarpicturesize' UPDATE [Setting] SET [Value] = N'415' WHERE [Name] = 'mediasettings.productthumbpicturesize' UPDATE [Setting] SET [Value] = N'550' WHERE [Name] = 'mediasettings.productdetailspicturesize' UPDATE [Setting] SET [Value] = N'100' WHERE [Name] = 'mediasettings.productthumbpicturesizeonproductdetailspage' UPDATE [Setting] SET [Value] = N'220' WHERE [Name] = 'mediasettings.associatedproductpicturesize' UPDATE [Setting] SET [Value] = N'450' WHERE [Name] = 'mediasettings.categorythumbpicturesize' UPDATE [Setting] SET [Value] = N'420' WHERE [Name] = 'mediasettings.manufacturerthumbpicturesize' UPDATE [Setting] SET [Value] = N'4' WHERE [Name] = 'catalogsettings.numberofbestsellersonhomepage' UPDATE [Setting] SET [Value] = N'true' WHERE [Name] = 'newssettings.shownewsonmainpage' UPDATE [Setting] SET [Value] = N'4' WHERE [Name] = 'shoppingcartsettings.crosssellsnumber' UPDATE [Setting] SET [Value] = N'6, 3, 9, 18' WHERE [Name] = 'catalogsettings.searchpagepagesizeoptions' UPDATE [Setting] SET [Value] = N'6, 3, 9' WHERE [Name] = 'catalogsettings.defaultcategorypagesizeoptions' UPDATE [Setting] SET [Value] = N'6, 3, 9' WHERE [Name] = 'catalogsettings.defaultmanufacturerpagesizeoptions' UPDATE [Setting] SET [Value] = N'6, 3, 9, 18' WHERE [Name] = 'catalogsettings.productsbytagpagesizeoptions' UPDATE [Setting] SET [Value] = N'6, 3, 9' WHERE [Name] = 'vendorsettings.defaultvendorpagesizeoptions' UPDATE [Setting] SET [Value] = N'3' WHERE [Name] = 'catalogsettings.recentlyviewedproductsnumber' UPDATE [Setting] SET [Value] = N'6' WHERE [Name] = 'catalogsettings.recentlyaddedproductsnumber' UPDATE [Topic] SET [DisplayOrder] = 5, [IncludeInFooterColumn1] = 1 WHERE [SystemName] = 'ShippingInfo' UPDATE [Topic] SET [DisplayOrder] = 10, [IncludeInFooterColumn1] = 1 WHERE [SystemName] = 'PrivacyInfo' UPDATE [Topic] SET [DisplayOrder] = 15, [IncludeInFooterColumn1] = 1 WHERE [SystemName] = 'ConditionsOfUse' UPDATE [Topic] SET [DisplayOrder] = 20, [IncludeInFooterColumn1] = 1 WHERE [SystemName] = 'AboutUs' END GO --a stored procedure update IF EXISTS ( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ProductTagCountLoadAll]') AND OBJECTPROPERTY(object_id,N'IsProcedure') = 1) DROP PROCEDURE [ProductTagCountLoadAll] GO CREATE PROCEDURE [dbo].[ProductTagCountLoadAll] ( @StoreId int ) AS BEGIN SET NOCOUNT ON SELECT pt.Id as [ProductTagId], COUNT(p.Id) as [ProductCount] FROM ProductTag pt with (NOLOCK) LEFT JOIN Product_ProductTag_Mapping pptm with (NOLOCK) ON pt.[Id] = pptm.[ProductTag_Id] LEFT JOIN Product p with (NOLOCK) ON pptm.[Product_Id] = p.[Id] WHERE p.[Deleted] = 0 AND p.Published = 1 AND (@StoreId = 0 or (p.LimitedToStores = 0 OR EXISTS ( SELECT 1 FROM [StoreMapping] sm with (NOLOCK) WHERE [sm].EntityId = p.Id AND [sm].EntityName = 'Product' and [sm].StoreId=@StoreId ))) GROUP BY pt.Id ORDER BY pt.Id END GO IF EXISTS ( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[DeleteGuests]') AND OBJECTPROPERTY(object_id,N'IsProcedure') = 1) DROP PROCEDURE [DeleteGuests] GO CREATE PROCEDURE [dbo].[DeleteGuests] ( @OnlyWithoutShoppingCart bit = 1, @CreatedFromUtc datetime, @CreatedToUtc datetime, @TotalRecordsDeleted int = null OUTPUT ) AS BEGIN CREATE TABLE #tmp_guests (CustomerId int) INSERT #tmp_guests (CustomerId) SELECT [Id] FROM [Customer] c with (NOLOCK) WHERE --created from ((@CreatedFromUtc is null) OR (c.[CreatedOnUtc] > @CreatedFromUtc)) AND --created to ((@CreatedToUtc is null) OR (c.[CreatedOnUtc] < @CreatedToUtc)) AND --shopping cart items ((@OnlyWithoutShoppingCart=0) OR (NOT EXISTS(SELECT 1 FROM [ShoppingCartItem] sci with (NOLOCK) inner join [Customer] with (NOLOCK) on sci.[CustomerId]=c.[Id]))) AND --guests only (EXISTS(SELECT 1 FROM [Customer_CustomerRole_Mapping] ccrm with (NOLOCK) inner join [Customer] with (NOLOCK) on ccrm.[Customer_Id]=c.[Id] inner join [CustomerRole] cr with (NOLOCK) on cr.[Id]=ccrm.[CustomerRole_Id] WHERE cr.[SystemName] = N'Guests')) AND --no orders (NOT EXISTS(SELECT 1 FROM [Order] o with (NOLOCK) inner join [Customer] with (NOLOCK) on o.[CustomerId]=c.[Id])) AND --no blog comments (NOT EXISTS(SELECT 1 FROM [BlogComment] bc with (NOLOCK) inner join [Customer] with (NOLOCK) on bc.[CustomerId]=c.[Id])) AND --no news comments (NOT EXISTS(SELECT 1 FROM [NewsComment] nc with (NOLOCK)inner join [Customer] with (NOLOCK) on nc.[CustomerId]=c.[Id])) AND --no product reviews (NOT EXISTS(SELECT 1 FROM [ProductReview] pr with (NOLOCK) inner join [Customer] with (NOLOCK) on pr.[CustomerId]=c.[Id])) AND --no product reviews helpfulness (NOT EXISTS(SELECT 1 FROM [ProductReviewHelpfulness] prh with (NOLOCK) inner join [Customer] with (NOLOCK) on prh.[CustomerId]=c.[Id])) AND --no poll voting (NOT EXISTS(SELECT 1 FROM [PollVotingRecord] pvr with (NOLOCK) inner join [Customer] with (NOLOCK) on pvr.[CustomerId]=c.[Id])) AND --no forum topics (NOT EXISTS(SELECT 1 FROM [Forums_Topic] ft with (NOLOCK) inner join [Customer] with (NOLOCK) on ft.[CustomerId]=c.[Id])) AND --no forum posts (NOT EXISTS(SELECT 1 FROM [Forums_Post] fp with (NOLOCK) inner join [Customer] with (NOLOCK) on fp.[CustomerId]=c.[Id])) AND --no system accounts (c.IsSystemAccount = 0) --delete guests DELETE [Customer] WHERE [Id] IN (SELECT [CustomerID] FROM #tmp_guests) --delete attributes DELETE [GenericAttribute] WHERE ([EntityID] IN (SELECT [CustomerID] FROM #tmp_guests)) AND ([KeyGroup] = N'Customer') --total records SELECT @TotalRecordsDeleted = COUNT(1) FROM #tmp_guests DROP TABLE #tmp_guests END GO --delete setting DELETE FROM [Setting] WHERE [name] = N'catalogsettings.loadallsidecategorymenusubcategories' GO