Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Web



                       E-Commerce using
                       Commerce Server 2009
                       Developi...
Customizing the Commerce Server SharePoint Site is possible            Adding a product to the catalogue could be seen as ...
BaseCatalog baseCatalog = (BaseCatalog)CommerceContext.Current.Ca-
 talogSystem.CatalogContext.GetCatalog(“Movie Catalog”)...
Upcoming SlideShare
Loading in …5
×

2009 9 Dutch Net Magazine Commerce Server By Nick Boumans Uk

652 views

Published on

Published in: Technology, Business
  • Be the first to comment

  • Be the first to like this

2009 9 Dutch Net Magazine Commerce Server By Nick Boumans Uk

  1. 1. Web E-Commerce using Commerce Server 2009 Developing wiDely usable e- commerce solutions using sharepoint Nick Boumans At the time of writing, the Netherlands has more than 20,000 online stores, a number which is continually expanding. Since SharePoint has become more widely deployed as an Internet solution, a requirement to have a SharePoint based e-Commerce-solution is now available. Previously the only option was to build a custom SharePoint solution, but now Microsoft Commerce Server 2009 can also be used for building a SharePoint based e-Commerce solution. Commerce Server 2009 is a Microsoft pro- duct for building E-Commerce systems, using .NET based web services and an abstract business layer, known as the Commerce Server Foundation. The first release of this product was in the year 1996, known as Site Server. The last release of Site Server was in 1998. In 2000 when they released it they renamed it to Commerce Server. The current version (2009) was released last March. The SharePoint Commerce Services are responsible for the integration between SharePoint and Commerce Server. The platform is also a fully Service Orientated (SOA) enabled plat- The SharePoint Default Site is a complete sample site inside Sha- form including BizTalk adapters. rePoint, using the Commerce Server Features. It’s possible to build your own E-commerce-solution in only a few steps, by defi- Advantages of Commerce Server 2009 ning your own catalogue and connecting it to the Default Site. will be noticed after running the SharePoint Commerce Services The available tools (Image 2), which connect using Web Services, wizard. Users have the ability to use some SharePoint Web Parts are very helpful for tasks like defining your catalogue. By using and the Default Site (Image 1). These Web Parts vary from a the “Catalogue and Inventory Schema Manager” tool it is possible Shopping basket Web Part to a “my Account” Web Part. A lot of to make schema definitions for categories and products. Once de- these Web Parts are customizable by XSLT. Also shipped is the fined you can then setup the properties for products and catego- CommerceSharePointExtensibilityKit which contains the sources ries within the catalogue. After this step a catalogue can be built of these Web Parts and User Controls, which could be very useful and filled using the “Catalogue Manager” (Image 3). for customizations. Original Article: Dutch .NET magazine | september 2009
  2. 2. Customizing the Commerce Server SharePoint Site is possible Adding a product to the catalogue could be seen as a “Hello by customizing the master page and CSS. A lot of Web Parts are World”-development example for Commerce Server. As I menti- using a template which uses XSL. These templates could be oned earlier in this article, the first step is getting access to the found in the Document Library “Commerce Server Templates”. Commerce Context and using this context for modifying the cata- So it is also possible to put your custom templates into this libra- logue. In Code sample 1 you can see how it’s possible to add a ry for use in the Web Parts. Using this method the most com- product to the catalogue. The last code line is may be the most mon customizations could be made. You can think about the important one since changes will not be saved by forgetting the order of the columns in the Shopping Basket Web Part. item.Save() procedure. // You have to add a reference to the Microsoft.CommerceServer.Ca- talog.dll //(CommerceSharePointExtensibilityKit) and the Development using the Commerce Server API makes it possible, // Microsoft.CommerceServer.Runtime.dll by using .NET code, to customize e.g. the Default Site. By refer- BaseCatalog baseCatalog = (BaseCatalog)CommerceContext.Current.Ca- ring some dll’s in your Visual Studio Project it will be possible to talogSystem.CatalogContext.GetCatalog(“Adventure Works Catalog”); Product item = baseCatalog.CreateProduct(“Tents”, “Iglo”, 30m, use these API’s. Commonly used dll’s are: “Tents”); Microsoft.CommerceServer.Runtime.dll item.DisplayName = “Iglo”; Microsoft.CommerceServer.Catalog.dll item[“Description”] = “3mm Tent”; Microsoft.Commerce.Portal.Common.dll item.Save(); CODESAMPLE 1: ADDING A PRODUCT TO A CATEGORY IN A CATALOGUE These dll’s could be found in the Web Part Extensibility Kit (CommerceSharePointExtensibilityKit). To make these dll’s avai- A Category definition describes the category in the catalogue. lable, you have to build the sample project from the Web Part Ex- This is a collection of properties which specify how information tensibility Kit at the first time, after signing it with your own has to be saved into a category. At the creation of a category defi- strong name key. The first step of development is the “Commerce nition, this definition will be added to the catalogue schema. Context”-class which could be found in the CommerceServer. To build a category definition: Runtime.dll. This class makes it possible to manage catalogues. For the best performance you only have to create one instance of 1. Create a category definition by using the CreateDefintion me- this object and reuse it during the lifetime of the application. thod of the CatalogContext object. 2. Create properties using the AddProperty method of the Cata- Development using the catalogue is one of the most common de- logDefinition object. velopment questions. In practice this will result in requirements 3. CatalogDefinition.Save() to save the definition. as: a Web Part inside SharePoint to show or manage products and categories. Beside the fact that this is possible using the Com- Code sample 2 creates a catalogue definition “Movie Category” by merce Server Tools or a Silverlight Web Part available from the creating a CatalogDefinition object. Microsoft Site, in most situations this solution doesn’t meet the public static void CreateCategoryDefinition(CatalogContext con- text) requirements of the customer. { // Create a category definition for categories in a DVD cata- log. CatalogDefinition categoryDefinition = context. CreateDefinition(“Movie Category”, CatalogDefinitionType.Category- Definition); categoryDefinition.Description = “Categories for DVDs”; No time for installing and // Create a description property for this category. CatalogProperty description = context. CreateProperty(“Description”, CatalogDataType.String, 500); configuring? You can download the // Add the property to the category definition. categoryDefinition.AddProperty(description.Name, Definition- Microsoft Commerce Server 2009 PropertyType.NormalProperty); // Save the definition. categoryDefinition.Save(); VPC and start today! } CODESAMPLE 2: BUILDING A CATEGORY DEFINITION Adding and deleting categories is the logical next step after crea- ting a category definition. The catalogue has two methods: Crea- teCategory and DeleteCategory. By adding a category you have to define a category definition. Code sample 3 and 4 shows how a category could be added and deleted by using the Catalog API. After deleting a category the method “PurgeDeletedItems” is res- ponsible for actual deleting items of the Catalog Database. Original Article: Dutch .NET magazine | september 2009
  3. 3. BaseCatalog baseCatalog = (BaseCatalog)CommerceContext.Current.Ca- talogSystem.CatalogContext.GetCatalog(“Movie Catalog”); // Add a category Category category = baseCatalog.CreateCategory(“MovieCategory”, “Adventure”); category.DisplayName = “Adventure”; category[“Description”] = “Adventure Movies”; category.Save(); CODESAMPLE 3: ADDING A CATEGORY ProductCatalog productCatalog = (ProductCatalog)CommerceContext. Current.CatalogSystem.CatalogContext.GetCatalog(“Movie Catalog”); // Delete the category productCatalog.DeleteCategory(“MovieCategory”); // Remove the deleted items from the catalog database productCatalog.PurgeDeletedItems(); CODESAMPLE 4: DELETING A CATEGORY Newbie using Commerce Server 2009? Maybe as a SharePoint developer you have not yet dived into Commerce Server; however, it is really worth a try. If you don’t want to spend any time on the installation and configuration be- fore you can exercise, as you can download a Microsoft Com- merce Server VPC from the Microsoft Connect site. Links Blog Nick Boumans: http://www.sharepointdevelopment.nl Commerce Server 2009 VPC: https://connect.microsoft.com/Downloads/Download- Details.aspx?SiteID=643&DownloadID=16926 MSDN Commerce Server 2009 Forum: http://social.msdn.microsoft.com/Forums/ en-US/commserver2009/threads Inline property editor webpart: http://www.microsoft.com/downloads/details. aspx?FamilyID=fce87672-90cf-4ead-b100-6bbc24d96f66&displaylang=en Nick Boumans, is SharePoint specialist and Microsoft Certified Trainer in the Nether- lands. Blog: http://www.SharePointDevelopment.nl. Original Article: Dutch .NET magazine | september 2009

×