Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

Virtual Catalog Search Is Unsuccessful When Both a Free Text and a SQL Query Are Set


View products that this article applies to.

Symptoms

The results of a query on a virtual catalog do not reflect the set price rule if both a SQLWhereClause property and a FreeTextSearchPhrase property are specified. If only the SQLWhereClause property is set or only the FreeTextSearchPhrase property is set, the returned prices have the price rule applied.

↑ Back to the top


Resolution

A supported hotfix is available from Microsoft. However, this hotfix is intended to correct only the problem that is described in this article. Apply this hotfix only to systems that are experiencing this specific problem. This hotfix might receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next software update that contains this hotfix.

If the hotfix is available for download, there is a "Hotfix download available" section at the top of this Knowledge Base article. If this section does not appear, contact Microsoft Customer Service and Support to obtain the hotfix.

Note If additional issues occur or if any troubleshooting is required, you might have to create a separate service request. The usual support costs will apply to additional support questions and issues that do not qualify for this specific hotfix. For a complete list of Microsoft Customer Service and Support telephone numbers or to create a separate service request, visit the following Microsoft Web site: Note The "Hotfix download available" form displays the languages for which the hotfix is available. If you do not see your language, it is because a hotfix is not available for that language. The English version of this fix has the file attributes (or later) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.
   Date         Time   Size     File name
   ----------------------------------------------------
   05-Mar-2003  20:34  602,939  Catalogcreate.sql
   06-Mar-2003  21:16   95,748  Catalogsp2migration.sql

				

↑ Back to the top


Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

↑ Back to the top


More information

To install this hotfix:
  1. Run the HotFixSetup.exe program. This replaces the CatalogCreate.sql file. Any new catalog in any language will have the hotfix already installed.
  2. Open Query Analyzer, and then run the CatalogSP2Migration.sql file. The script updates the stored procedures and drops and re-creates the catalog scratch database.

Steps to Reproduce the Behavior

The following code causes the problem to occur:
private void SimpleCatalogSearch()
		{
			// This allows you to search a Commerce Server Catalog using 3 filters:
			// 1) Category
			// 2) Keywords (Free text)
			// 3) Price range and product status (SQL Clause)
			// This also uses custom paging on a datagrid to only bring back the exact number of records per page.
			// Created Waterfront Partners 08/13/02
			// INPUTS: HashTable that contains the "search form" 
			// Category, keyword(s), price range and products per page to display
			
			try
			{
				// Get the search options from the session.
				Hashtable htSearchOpts = (Hashtable)Session[SESSION_CAT_SEARCHCRITERIA];
				
				// Create a Catalog Search class.
				CatalogSearch csSearch = new CatalogSearch( CommerceContext.Current.CatalogSystem );
				// Set the catalog name.
				csSearch.CatalogNames = htSearchOpts["Catalog"].ToString();

				// Set the category if any check against the default const.
				if ( htSearchOpts["Category"].ToString() != UI_DROPDOWNLIST_DEFAULT_VALUE )
				{
					csSearch.CategoryName = htSearchOpts["Category"].ToString();
				}
				
				// Build the SQL string for further filtering.
				// Return only active products.
				StringBuilder sbSql = new StringBuilder();
				sbSql.Append( "status = 'Active'" );
				// Now determine if you have a PRICE RANGE to search on.
				if ( ( htSearchOpts["P1"].ToString() != "" ) && ( htSearchOpts["P2"].ToString() != "" ) )
				{
					sbSql.Append( " and [cy_list_price] between " );
					sbSql.Append( htSearchOpts["P1"].ToString() );
					sbSql.Append( " and " );
					sbSql.Append(htSearchOpts["P2"].ToString();
				}
				else if ( (htSearchOpts["P1"].ToString() != "" ) && ( htSearchOpts["P2"].ToString() == "" ) )
				{
					sbSql.Append( " and [cy_list_price] >= " );
					sbSql.Append( htSearchOpts["P1"].ToString();
				}
				else if ( ( htSearchOpts["P1"].ToString() == "" ) && ( htSearchOpts["P2"].ToString() != "" ) )
				{
					sbSql.Append( " and [cy_list_price] <= " );
					sbSql.Append( htSearchOpts["P2"].ToString();
				}
				
				// Set the SQL WHERE clause.
				csSearch.SqlWhereClause = sbSql.ToString();

				// Set the free text phrase (key words), if any.
				if ( htSearchOpts["KeyWords"].ToString() != "*" )
				{
					csSearch.FreeTextSearchPhrase = htSearchOpts["KeyWords"].ToString().Replace( "-", " and " );
				}
				// Now set up a search options object.
				CatalogSearchOptions csOptions = new CatalogSearchOptions();
				// Properties to return
				csOptions.PropertiesToReturn = "[ProductName], [LongDesc], [ImageSmallFileName], [ImageLargeFileName], [Manufacturer], [Product_ID], [WFP_ID], [SKU], [cy_list_price], [ProductID]";
				// Product class to return - no variants here
				csOptions.ClassTypes = CatalogClassTypes.ProductClass | CatalogClassTypes.ProductFamilyClass;
				// For now sort on Manufacturer, Price ascending
				csOptions.SortProperty = "[Manufacturer], [cy_list_price]";
				csOptions.SortAscending = true;
				// Set the paging stuff.
				// The search has been set up to use a datagrid custom paging method.
				// Only return the amount of records that will fit on a page.
				csOptions.StartingRecord = m_iStartIndex;
				csOptions.RecordsToRetrieve = Convert.ToInt32( htSearchOpts["PPP"] );

				// Set the options into the search object.
				csSearch.SearchOptions = csOptions;
				
				// Set the page size.
				// Execute the search and BIND depending on WHERE you are coming in.
				// If not a post back then a first time search so set the page count
				// in the viewstate and in the datagrid virtual item count.
				DataSet daResulst;
				int iSearchResults = 0;
				daResulst = csSearch.Search(out iSearchResults);
				// Set the virtual item count for custom paging.
				dgResults.VirtualItemCount = iSearchResults;
				if ( iSearchResults > 0 )
				{
					lblSearchResultMSG.Text = "Your search has found " + iSearchResults.ToString("#,#0") + " product(s).";
					SubSequentVisit();
				} 
				else 
				{
					NoResultsFound();
				}
				dgResults.DataSource = daResulst.Tables[0];
				// Set up the paging options for all.
				dgResults.PageSize = Convert.ToInt32( htSearchOpts["PPP"] );
				dgResults.DataBind();
			}
			// The following errors are catalog search errors. In all cases we will report to the user
			// that no results have been found.
			catch ( ArgumentOutOfRangeException )
			{
				NoResultsFound();
			}
			catch ( ArgumentNullException )
			{
				NoResultsFound();
			}
			catch ( CatalogException ce)
			{
				Logging.LogError( "Catalog Exception Error - " + ce.Message );
				Logging.LogError( "Catalog Inner Exception Error - " + ce.InnerException );
				NoResultsFound();
			}
			catch ( Exception e)
			{
				Logging.LogError( "Catalog General Error - " + e.Message );
				NoResultsFound();
			}
		}

↑ Back to the top


Keywords: KB814071, kbfix, kbbug, kbqfe, kbhotfixserver, kbautohotfix

↑ Back to the top

Article Info
Article ID : 814071
Revision : 7
Created on : 11/15/2007
Published on : 11/15/2007
Exists online : False
Views : 341