Thursday, September 13, 2007

Setting Up Profile System In Commerce Server 2007



Well, i am gonna explain how to set up the profile system on the commerce server API.


Well to start of open the Commerce Manager. The Commerce Manager is the whole sum of all the services of Commerce. Now the Commerce Profile API can be explained by the above image.
If you look at the above image, it shows the entire Commerce Profile Heirarchy.
Now lets get started on our main task. To Set up Profile System, go to the Commerce Site node. Click on the option to Add a resource in the site. Browse to the default CSharp.pup when asked and in that select the profile item. Now as soon as you do that your Profile Db and schema are generated. The Profile Schema is visible inside the Commerce Manager itself.
To access the profiles, Go to the Global Resource node. In that you will find the Product Catalog. In paralled to Product Catalog is the site terms.
Site Terms are the properties with multiple value. These can be referred as properties which can have multiple values. For example we can have a site term called year which have all the months of the year.
The Second Node "Product Catalog" is the one which carries that two important things "Profile Definition" and "Data Source".
The DataSource has properties mapped directly to the DB, whereas Profile Definitions are the actual entities which carry the properties in which values are given in the user specific end.
Concluding the post, this system of all the systems is most user friendly and very easy to use.

Profile System

Well one of the intresting topic in Commerce is the Profile System. I believe that you know of a asp.net Membership scenerio. Well in Blogs a UserProfile if logged in is stored in the CommerceContext.Current.UserProfile
Now, in this blog I will explain the process of registration.

Firstly we provide a UserId. In my case i am using a asp.net User registration Wizard
// Set new user id. CommerceContext.Current.UserID = ((Guid)Membership.GetUser(UserRegWizard.UserName).ProviderUserKey).ToString();


Then we set the Commerce Profile :
commerceProfile.Profile currUserProfile = objUpmProfileProvider.GetCommerceProfile("GeneralInfo.email_address", TbxUserEmail.Text.Trim(), "UserObject");

Commerce has inbuilt Properties, you can make new properties using the Commerce Manager.

I will explain this in detail in another blog.


So Now we can set various properties of the commerce like
currUserProfile["GeneralInfo.first_name"].Value = userFirstName.Text.Trim();
After Setting the Properties to store it we do.
currUserProfile.Update();
Hence we just created a new user.
Hope the post is helpfull.

Wednesday, January 24, 2007

Catalog Search Over Explicit Search

In commerce server, the catalog search has been known to be the most easiest and flexible way to pull out effective needy data from the catalog system. However, this may be not true in some cases. In a catalog search , we are not taking into consideration that by catalog search we allow the commerce to search for each and every product within the given condition. This consumes more of time and effort. So hence a explicit search is always preferred over the catalog search.

Pulling Out the Catalog Context

The Catalog Context is a very important part of the Catalog System of the Commerce Server. The catalog context is the only way through which can pull out catalogs,categories and work with them. One thing very smart in a commerce application is that the commerce context is defined at the time of creation of the commerce website. This means that as soon as we create a new commerce server website the commerce context is defined or initialized in the web.config of the application. So hence to call or initialize the catalog context we can directly use the web.config's commerce context. This can be done in the following manner :
return CommerceContext.Current.CatalogSystem;
So hence we see that instead of explicit catalog context call, we can directly initialize the catalog context. This may seem to be a very small thing, but on the contrary if your application is big enough, it will certainly boost up the speed of the application. This is due to the fact that if you explicitly call the catalog content using the siteagent i.e by doing:

//Create a CatalogSiteAgent to connect to the database.
CatalogSiteAgent catalogSiteAgent = new CatalogSiteAgent();
catalogSiteAgent.SiteName = "Give the appropiate sitename";

//Create the CatalogContext object.
CatalogContext catalogContext = CatalogContext.Create(catalogSiteAgent);
return catalogContext;

By doing this, you may get the same catalog context, however it may be initialized n number of times for n number of calls. Hence the first method is quite efficient and effective.