Showing posts with label CommerceServer. Show all posts
Showing posts with label CommerceServer. Show all posts

Friday, December 16, 2011

Introduction to Commerce Server 2009

I was recently  given a Commerce Server technical session in my present company.I really enjoyed presenting the session with very enthusiastic Participants.
                               It was a good opportunity to give session on Commerce Server 2009.I enjoyed giving answers to the participants.
I have promised to all the participants that I will soon take more sessions on Commerce Server(Multi channel,Extending Order,Line items,Commerce Server Admin console,Commerce Server API etc..)
.Attached one of the presentation here.


IntroductionToCS


Tuesday, October 26, 2010

Get product by category using commerce server

                         Recently we got a problem with in our application that is some product's bread crumb not displaying properly .I have investigated and find the problem.
Problem:       The problem is when product is associated with two categories it is always fetching from primary parent  category .
       
Example :
             when product associated with two categories A and category B .It always fetch from category A even though we request for category B product .
                    If you don't have much knowledge on Commerce server API then get from knowledge  from here.....
                             
  Runtime Commerce Server APIs (those that are used to retrieve info for use in a e-commerce website)
    * ProductCatalog: Getting products from a catalog along with its child products
    * CatalogContext.GetCatalogs: Getting a set of catalogs from the current context
    * CatalogContext.GetCategory: Getting the details of a category including child categories
    * CatalogContext.GetProduct: Getting the details of a product and product family including the variants
    * CatalogSearch: Searching the catalog with the basic properties specified
   
Here is the code for Fetching product based on product id and Category
/// <summary>
       /// Method:GetProduct
       /// Description: This method is used to get the Product Information based on productId and CategoryName .
       /// </summary>
       /// <returns>datatable</returns> 
       public static DataTable  GetProductByCategory(string currentCatalog, string categoryName, string productId, string language)
       {
           ProductCatalog virtualCatalog = CommerceContext.Current.CatalogSystem.GetCatalog(currentCatalog);
           Category virtualCatalogCategory = virtualCatalog.GetCategory(categoryName);
           DataSet dsProducts =  virtualCatalogCategory.GetProducts();  
           DataView dvFilteredProducts = dsProducts.Tables[0].DefaultView;
           dvFilteredProducts.RowFilter = "ProductId='" + productId + "'";
           return dvFilteredProducts.ToTable();
       }