Catalog classtypes and search functionality in the catalog system
The catalog component in the Runtime BCLs contains an enumeration named CatalogClassTypes. This enumeration is very useful when it comes to searching the catalog data or browsing categories in a catalog especially since it allows you to specify the type of catalog items that should be returned by the method.
The following are the various fields in this method:
CategoryClass, represents a category in the catalog.
ProductClass, represents a product in the catalog.
ProductFamilyClass, represents a product family in the catalog.
ProductVariantClass, represents a product variant in the catalog.
In addition to these class types which represent physical entities in a catalog there are two logical class types which control how catalog entities of the type ProductFamilyClass and ProductVariantClass are returned.
ProductFamilyForVariantsClass, returns the product families for all the variants that satisfies the specified search condition. For eg, consider a Books catalog which contains a book represented as a product family and is named “The secret of success”. This book has two variants with a variant property Binding having values “eBook” and “HardBack”. If you want to display all the eBooks in the Books catalog then you can specify the search condition “Binding=’eBook’” and ProductFamilyForVariantsClass as the classtype. This will match the eBook variant but return you the ProductFamily record which can be displayed on the site.
ProductVariantsForFamilyClass, returns the product variants for all the product families that satisfies the specified search condition. In the above e.g., specifying Name=“The secret of success” and ProductVariantsForFamilyClass as the classtype will return all the variants for the above product family.
The following code sample demonstrates the search functionality and the usage of the class types. This sample searches all the products, product families and product variants in the Books catalog for the phrase “comics” and having a price less than 10 and returns a dataset containing the products and product families. The dataset is sorted(ranked) by the relevance of the freetext search results.It uses the ProductFamilyForVariantsClass class type to search the variants but return the ProductFamily recods for these variants instead.
CatalogContext catalogContext = CommerceContext.Current.CatalogSystem;
CatalogSearchOptions catalogSearchOptions = new CatalogSearchOptions();
catalogSearchOptions.ClassTypes = CatalogClassTypes.ProductClass |
CatalogClassTypes.ProductFamilyClass |
CatalogClassTypes.ProductFamilyForVariantsClass;
catalogSearchOptions.PropertiesToReturn = "[ProductId],[VariantId],[Name],[FreeTextSearch_Rank]";
catalogSearchOptions.SortProperty = "[FreeTextSearch_Rank]";
catalogSearchOptions.SetPaging(1, 20);
CatalogSearch catalogSearch = new CatalogSearch(catalogContext);
catalogSearch.SearchOptions = catalogSearchOptions;
catalogSearch.Language = "en-US";
catalogSearch.CatalogNames = "Books";
catalogSearch.FreeTextSearchPhrase = "comics";
catalogSearch.SqlWhereClause = "[cy_list_price] < 10";
int totalRecords = 0;
DataSet catalogSearchResults = catalogSearch.Search(out totalRecords);
In addition the product catalog system supports the following search functionality
Combined freetext and property based searches on one or more catalogs
Recursive or non-recursive freetext searches on a category in a catalog.
Recursive or non-recursive property based searches on a category in a catalog.
Recursive or non-recursive combined freetext and property based searches on a category
Comments
Anonymous
May 21, 2006
One of my posts (Catalog classtypes and search functionality in the catalog system) described the search...Anonymous
June 17, 2006
Two years back in this post on fulltext search in the catalog system, I had explained how fulltext searches...Anonymous
October 07, 2006
Two years back in this post on fulltext search in the catalog system , I had explained how fulltext searchesAnonymous
May 29, 2009
PingBack from http://paidsurveyshub.info/story.php?title=vinayak-s-weblog-catalog-classtypes-and-search-functionality-in-the