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.