views:

16

answers:

2

I have a Sharepoint 2007 internet site using Microsoft commerce server 2009.

I need to show a list of "Recently added products" or "featured products". These will be showing products from "all" catalogs.

What is the best approach to implement such requirement?

A: 

Hi Emad,

Have you got the solution for the same? I am also looking for its implementation approach. So would appreciate if you can post the reply, if found.

Shalini
A: 

To achive that you could simple run a product search using LastModified field to filter recently created products by date.

You'll need to set the catalogs you want to search for, since you said you have to search in all of them.

I believe the code snippet below is what you need. Remember you'll need full-text search up and running to get results from the search.

var queryBuilder = 
        new CommerceQuery<Product, CommerceCatalogFullTextSearchBuilder>();

queryBuilder.SearchCriteria.FullTextSearchType = CommerceFullTextSearchType.FreeText;
queryBuilder.SearchCriteria.Catalogs.Add("MyCatalogName1");
queryBuilder.SearchCriteria.Catalogs.Add("MyCatalogName2");
queryBuilder.SearchCriteria.Catalogs.Add("MyCatalogName3");
queryBuilder.SearchCriteria.WhereClause = "LastModified > '2010-10-01'";

CommerceQueryOperationResponse response =
    (CommerceQueryOperationResponse)new OperationServiceAgent()
        .ProcessRequest(requestContext, queryBuilder.ToRequest())
        .OperationResponses[0];

List<Product> products = new List<Product>();
if (response.CommerceEntities != null && response.CommerceEntities.Count > 0)
{
    foreach(var p in response.CommerceEntities)
    {
        products.Add((Product)p);
    }
}

return products;
alexfgo