Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

Searching for Catalog Entries with Specific MetaField Data

Vote:
 

Hi, 

I have been trying to find catalog entries that have a certain MetaField value set, e.g. a DisplayName that equals Canon. The example below is taken from:

http://sdk.episerver.com/commerce/1.1/Content/Developers%20Guide/Catalog%20System/Catalog%20Product%20Search.htm

 private void testCatalogEntiresSearch()

{
CatalogSearchParameters parameters = new CatalogSearchParameters();
parameters.SqlMetaWhereClause = "Meta.DisplayName = 'Canon'";
CatalogSearchOptions options = new CatalogSearchOptions();
options.Classes.Add("Brands");
options.RecordsToRetrieve = 20;
Entries result = CatalogContext.Current.FindItems (parameters, options, new CatalogEntryResponseGroup());
}

I can retrieve a result by uncommenting the "parameters.SqlMetaWhereClause" and the "options.Classes.Add("Brands");", but the result returned is too big, and contains unnecessary data - i don’t want to
handle that amount of data on each request.

Does anyone of you guys know how to get this working?

/Tim

#50457
May 03, 2011 9:43
Vote:
 

Hi Tim,

If you want to find by the display name of product, then you can use SqlWhereClause instead of SqlMetaWhereClause.

I use following sample code and return 25 records:

private void testCatalogEntiresSearch()
{
    CatalogSearchParameters parameters = new CatalogSearchParameters();
    parameters.SqlWhereClause = "1=1 AND Name LIKE '%Canon%'";
    CatalogSearchOptions options = new CatalogSearchOptions
                                        {
                                            RecordsToRetrieve = 50,
                                            CacheResults = false,
                                            StartingRecord = 0,
                                            ReturnTotalCount = true
                                        };
    Entries result = CatalogContext.Current.FindItems(parameters, options, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull));
    Response.Write(result.TotalResults);
}

Hope this helps,

/DL

#50498
May 04, 2011 9:16
Vote:
 

Thanks a lot for you answer, we tried your solution and it worked out fine. 

We did however (in some cases) go over to use none-commerce caching instead of the parameters CacheResults alternative shown above. This due to that we have higher performance needs some scenarios.

/Tim

#51132
May 25, 2011 10:04
Vote:
 

Hi,

Is there a metadata for the displayprice? Or another way to obtain it using a sql query?

Regards

 

#64962
Edited, Jan 16, 2013 23:51
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.