Commerce Server Blog

Build world class ecommerce applications using Microsoft Commerce Server
  •  
  • Home
  • Advertise
  • Copyright Policy
  • Disclaimer
  • About

Catalog Importer

ravikanth | May 27, 2008

Ecommerce application needs product updates daily or frequently to show up to latest products information on their website. Sometimes the product information gets from company business users and sometimes the products information comes from vendors. For large scale ecommerce application, middleware servers like BizTalk are used for product import.

This current tool (attached to this article) is command based tool and be perfect for small companies with limited data upload and can be used only one time (during application migration) or regularly. This tools takes catalog data using excel file and through commerce server API, it inserts data into database.

The excel file template contains three sheets.

1.    First sheet name  is “CategoryData” – This sheet contains categories details.
2.    Second sheet name is “ProductData” – This sheet contains product details.
3.     Third Sheet name is “VariantData” – This sheet contains variant data.

Note: Kindly don’t change sheet names.

When the tool is executed, it will ask for data excel file path. Once correct path is provided, it will ask whether to import category data, product data or variant data. Based on the option selected, the tool starts porting data into commerce server.

The assumption is that the given catalog and product definition are created in commerce server.

How to add a category?

Category can be created under a Catalog only. So, before we create category, the application should get context of Catalog, then by using method CreateCategory(), category can be created.

BaseCatalog baseCatalog = (BaseCatalog)context.GetCatalog((string)row["CatalogName"]);
Category category = baseCatalog.CreateCategory((string)row["CategoryDefinition"], (string)row["CategoryName"]);
category.DisplayName = (string)row["DisplayName"];
category.Save();

How to add a Product?

Product can be created under catalog or category. So before we create product, the application should get catalog context. By using CreateProduct(), a product can be created. If the products need to be created under a category, then pass category information to CreateProduct() method.

BaseCatalog baseCatalog = (BaseCatalog)context.GetCatalog((string)row["CatalogName"]);
Product product = baseCatalog.CreateProduct((string)row["ProductDefinition"], (string)row["ProductID"], Convert.ToDecimal(row["ListPrice"]), (string)row["CategoryName"]);
product.DisplayName = (string)row["DisplayName"];
product["Image"] = row["Image"];
product["Description"] = row["Description"];
product.Save();

How to add a variant?

Products may or may not have a variant. For example, a shoe can have multiple variants like size, color, etc and some products don’t have variants like Books. To create a variant, the application should get product definition and to get product definition, the application needs to get catalog context. Once product definition obtained, we can add a new variant using AddVariant() method as shown below.

BaseCatalog baseCatalog = (BaseCatalog)context.GetCatalog((string)row["CatalogName"]);
ProductFamily productFamily = (ProductFamily)baseCatalog.GetProduct((string)row["ProductID"]);string variantID = (string)row["VariantID"];
// Add the variant to the product family.
productFamily.AddVariant(variantID);
// Set the properties for the variant product. 
productFamily.Variants[variantID]["VariantActualPrice"] = Convert.ToDecimal(row["VariantListPrice"]);
productFamily.Variants[variantID]["Color"] = (string)row["VariantColor"];
productFamily.Variants[variantID]["Size"] = (string)row["VariantSize"]
productFamily.Variants[variantID]["VariantDisplayName"] = (string)row["VariantDisplayName"];
productFamily.Save();

If you have any questions/suggestions on his approach, feel free to send your comments. Click here to download Catalog Importer.

Categories
commerce server 2007
Tags
Catalog, catalog import, Category, commerce server, commerce server 2007, data importer, Product, tools, Variant
Comments rss
Comments rss
Trackback
Trackback

« Failed to set value for profile property cc_number Microsoft Commerce Server 2007 SP2 »

2 Responses to “Catalog Importer”

  1. Ralf Hoeppner says:
    July 25, 2008 at 5:07 pm

    Hey Ravi,

    thanks for sharing that with us! – This is exatly what I was looking for…

    best,
    Ralf

    Reply
  2. Commerce Server Blog » Commerce Server Profile Importer Tool says:
    July 14, 2010 at 2:05 am

    [...] years back, I have blogged catalog importer, which will help us to import catalog data into commerce server. I have used this tool in many [...]

    Reply

Leave a Reply

Click here to cancel reply.

Sign up for Newsletter


Categories

Quiz

  • Catalog Quiz for Beginners
  • Profile Quiz for Beginners
  • Quiz 1 for Advance Users
  • Quiz for Beginners

Recent Posts

  • Staging Deployment – Security Considerations
  • Pipeline Editor displays registered custom pipeline components as unknown in 64 Bit version.
  • How commerce server staging works
  • Steps to extend payments in Commerce Server 2009
  • Introduction to Commerce Server Staging
  • Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information
  • Commerce server staging throws Remote authorization failed to server. Ensure the service has access to this server.
  • Updated Commerce Server 2009 template pack for SharePoint 2007 released
  • RCXml2Resx.exe tool stops working
  • Commerce Server Profile Importer Tool

Archives

  • August 2010
  • July 2010
  • June 2010
  • May 2010
  • April 2010
  • March 2010
  • February 2010
  • January 2010
  • December 2009
  • November 2009
  • October 2009
  • September 2009
  • August 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009
  • March 2009
  • February 2009
  • January 2009
  • December 2008
  • November 2008
  • October 2008
  • September 2008
  • August 2008
  • July 2008
  • June 2008
  • May 2008
  • April 2008

Tags

add discounts add images to profile Advantages of commerce server approve discounts authentication auto login process automatic user creation basket Brand Management business tools campaign management Catalog catalog import Category commerce server commerce server 2007 commerce server manager Commerce Server SP2 commerce server staging discounts ecommerce Estimation Installation inventory Kanth Koppala marketing system migration error Mojave operation components operation sequence Order subsystem Product profile profile subsystem property metadata purchase order quick checkout Ravi Ravi Kanth site cache refresh starter site tools transactions error Variant
(c) 2009 Commerce Server Blog. All rights Reserved. Articles cannot be reproduced without permission from the author.Write to me at kanth@ravikanth.net if you have any comments, questions, suggestions about this site or would like to send us a tip
About Us | Terms of Use | Disclaimer | Advertise .