The article describes an issue with CatalogContext.Current.FindItems when searching with multiple meta field conditions in the SqlMetaWhereClause. In addition, if there are CatalogSearchOptions.Classes being used this will also cause issue with results.
Here is a sample code that illustrates this issue with both items.
CatalogSearchParameters pars = new CatalogSearchParameters(); CatalogSearchOptions options = new CatalogSearchOptions { CacheResults = false, RecordsToRetrieve = 10 }; options.Classes.Add('Class1'); options.Classes.Add('Class2'); pars.Language = "fr"; pars.SqlMetaWhereClause = "(META.MetaFieldName = 'Status' AND META.Number <> 300)"; pars.SqlWhereClause = "(MetaClassId=29 OR MetaClassId=30) AND IsActive = 'true'"; pars.CatalogNames.Add("Store"); Entries tmpEntries = CatalogContext.Current.FindItems(pars, options, new CatalogEntryResponseGroup());
There are two issues in play here.
Unable to search for entries by multiple conditions in SqlMetaWhereClause
CatalogSearchOptions.Classes does not work
Product Development Engineeering is aware of these issues and states the following workarounds.
- The workaround is to do multiple queries and intersect the results
- The second component to the workaround is to match on the meta class ID instead of meta class name.
Please sign in to leave a comment.