다음을 통해 공유


CatalogSearchOptions Class

For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.

Provides properties to customize the catalog search results when performing searches on one or more catalogs.

Namespace:  Microsoft.CommerceServer.Catalog
Assembly:  Microsoft.CommerceServer.Catalog (in Microsoft.CommerceServer.Catalog.dll)

Syntax

'Declaration
Public Class CatalogSearchOptions _
    Inherits CommonSearchOptions
'Usage
Dim instance As CatalogSearchOptions
public class CatalogSearchOptions : CommonSearchOptions
public ref class CatalogSearchOptions : public CommonSearchOptions
public class CatalogSearchOptions extends CommonSearchOptions

Remarks

You can use properties in this class to customize the search results. You should create an instance of the class, set the appropriate properties and pass it as a parameter to the Search method to apply the filter criteria.

A CatalogSearchOptions object can be provided to catalog methods that perform a database search to specify which records to return, how to sort the result set, and so on. Note that not all methods respect all of the settings. When the site is run in Debug mode or Checked mode, a warning message will be logged to the active DebugContext object whenever a setting has been made that cannot be respected.

The maximum number of results returned by a Catalog Search is limited by the MaxSearchResults value in the catalog webservice web.config. This limits the returned collections for a CatalogSearch, ChildProducts (ChildProducts, ChildProducts), ChildCategories (ChildCategories, ChildCategories), and Variants (Variants, Variants) Collections. It does not affect ParentCategories, AncestorCategories and CanonicalCategories collections.

Examples

internal CatalogItemsDataSet SearchCatalog(string catalogName)
{
  CatalogSearchOptions searchOptions = new CatalogSearchOptions();
  searchOptions.PropertiesToReturn = "CategoryName, DefinitionName, i_classtype, ProductId, VariantId, DisplayName";
  searchOptions.SetPaging(1, 20);
  searchOptions.SortProperty = "CategoryName";
  CatalogSearch catalogSearch = this.catalogContext.GetCatalogSearch();
  catalogSearch.CatalogNames = catalogName;// This is a comma separated list of catalogs to search eg "Catalog1,catalog2"
  catalogSearch.SqlWhereClause = "cy_list_price<10";// Return all items with price less than 10
  catalogSearch.UseAdvancedFreetextSearch = true;// 
  catalogSearch.AdvancedFreeTextSearchPhrase = "\"sql books\""; // Returns all rows which contain the phrase "sql books"
  /*
   *  Inventory Integration: Set the inventory options here
    catalogSearch.InventoryOptions = new InventoryOptions();
    catalogSearch.InventoryOptions.FilterOutOfStockSkus = true; // Do not return products which are out of stock
  
   */
  /* To restrict searches to  a single category
  catalogSearch.CategoryName = "categoryname";
  catalogSearch.Recursive = true;
   */
  int totalRecords = 0;
  CatalogItemsDataSet catalogItems = catalogSearch.Search(out totalRecords);
  Console.WriteLine(totalRecords);
  foreach (CatalogItemsDataSet.CatalogItem catalogItem in catalogItems.CatalogItems)
  {
    Console.WriteLine(catalogItem.CategoryName);
    Console.WriteLine(catalogItem.DisplayName);
  }
  return catalogItems;
}

Inheritance Hierarchy

System..::.Object
  Microsoft.CommerceServer.Catalog..::.CommonSearchOptions
    Microsoft.CommerceServer.Catalog..::.CatalogSearchOptions

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

CatalogSearchOptions Members

Microsoft.CommerceServer.Catalog Namespace