// Search a catalog
// name="catalogName"
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;
}