Boite à outils Office

Don’t forget the ProductConfiguration / CategoryConfiguration in your Commerce Server development

Commerce Server, Development 3 Comments »

These last few weeks, I have been involved with several Commerce Server reviews, and I have noticed that a lot of CS implementations was done without 2 important settings, which are:

These two classes inherit from Microsoft.CommerceServer.Catalog.CatalogItemConfiguration, and they are used to load only the objects you use. Why? Because when you want to display the product price or its description for example, you do not need to get its ancestors, variants, related products so you can have a simple and lighter Product or Category

Besides, if you have a look into the API via Reflector, you will see that the CategoryConfiguration or ProductConfiguration class is always instantiate if you’re not setting up one (ie, the CS framework choose for you the objects to populate):

image image

To demonstrate to importance of those classes, let’s go through a simple exemple of product implementation where you only need to show the productID, the price and the display name:

  • Without a ProductConfiguration, we use:
Product product = catalogCtx.GetProduct("Adventure Works Catalog", "AW029-03");
Console.WriteLine("Pid: " + product.ProductId
                + " - " + product.DisplayName
                + " - " + product.ListPrice);

With the SQL Profil we are able to get the SQL calls and discover that 2 stored procedures are call:

image 

Read the rest of this entry »

How to sort different Commerce Server properties in a different order

Commerce Server, Development No Comments »

To follow up a thread in Commerce Server forum: How could i sort by property1 ASC and property2 DESC in a catalog search?, I was surpised that one of the basic Commerce Server feature was not understanding.

It’s a common task in e-Commerce to sort a products’ list (or for a category) in different way for different properties, ie property1 ascending and property2 descending and keep the paging stuck to those properties ordering.

The Ravi’s solution was to use a dataview. But the main issue here is that you can only sort the result returning by the CatalogSearch! What append if you have multiple pages? And on top of that, the poor performance to sort with a DataView…

To achieve this, you simply need to use the common search CatalogSearch class. You just have to surround the propery with sqaure brackets and then the order way:

CatalogSearch catalogSearch = catalogContext.GetCatalogSearch();
catalogSearch.CatalogNames = "MyCatalog";
catalogSearch.SearchOptions.ClassTypes = CatalogClassTypes.ProductFamilyClass;
catalogSearch.SearchOptions.PropertiesToReturn = "ProductId, cy_list_price";
catalogSearch.CategoriesClause = "CategoryName = 'CatId";
catalogSearch.SqlWhereClause = "Display = 'OK'";
catalogSearch.SearchOptions.SortProperty = "[ProductId]ASC, [cy_list_price]DESC";

Be careful, it’s very important to haven’t got any space between the ordering way and the right square bracket.

For information, our Commerce Server developer senior, Anoir, have already wrote a post about it (in french :) ): Recherche d’un produit avec plusieurs colonnes de tris différenciés in the Altima’s blog.

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in
Creative Commons License