Commerce Server Blog

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

Adding Image to Profile Sub-System

ravikanth | July 25, 2008

Commerce server profile will provide lot of advantages to developer by allowing extending it as per client business needs. In this article we are discussing how to add an image to use profile. Personalization is currently hot topic in the market and in this article we are extending our profile system to store user image in his profile. This image can be used to display in reviews/communities in ecommerce site.

There are two days we can implement this solution

1.       Store image in file system and the file path in database.

2.       Store image in the database.     

In the current article we are storing image in the database.

Follow these steps

1.       Create a new field named “u_UserImage” of type “Image” in UserObject table (This is  used to store user image).

ALTER TABLE dbo.UserObject ADD

                u_UserImage image NULL

GO

2.       Open commerce server manager. Expand Profile-> profile Catalog-> Data Sources-> ProfileService_SQLSource->DataObjects-> UserProfile.

3.       Right click on User Object and click on “Add Data Member” and enter text as shown in the image.

4.       Open commerce server manager. Expand Profile-> profile Catalog-> Profile Definitions and click on User object.
Add Data Member

5.       Click on General Information and click on Add Property and add values as shown in the image below.

 

Add Property
6.
      
In your registration page, add a input field of type file.

7.      

Add following code at submit button click event.

 

// Reading file content.

Stream s = File.OpenRead(filePath);
byte[] buffer = new byte[s.Length];
s.Read(buffer, 0, (int)s.Length);
s.Dispose();
s.Close();      

//Creating an user profile.

Profile userProfile = profileContext.CreateProfile(newId.ToString(), “UserObject”);
userProfile.Properties["GeneralInfo.user_id"].Value = newId.ToString();
userProfile.Properties["GeneralInfo.first_name"].Value = txtbox_FirstName.Text.ToString();
userProfile.Properties["GeneralInfo.last_name"].Value = txtbox_LastName.Text.ToString();
userProfile.Properties["GeneralInfo.email_address"].Value = txtbox_Email.Text.ToString();
userProfile.Properties["GeneralInfo.user_security_password"].Value = txtbox_Password.Text.ToString();
userProfile.Properties["GeneralInfo.user_type"].Value = 1;
userProfile.Properties["GeneralInfo.language"].Value = “en-US”;
userProfile.Properties["GeneralInfo.password_question"].Value = txtbox_PasswordAns.Text.ToString();
userProfile.Properties["GeneralInfo.password_answer"].Value = txtbox_PasswordAns.Text.ToString();
userProfile.Properties["GeneralInfo.image"].Value = buffer;   
userProfile.Update();

 

If you would like to have multiple images for a profile then better to create a table for all profile images. Each entry will have a unique ID and image content. Create a data object in commerce server. Extend userObject to hold a array of user images – i.e., unique Ids(as similar to storing multiple address).

Comments
3 Comments »
Categories
commerce server 2007
Tags
add images to profile, commerce server, extending profile sytem, Profile System
Comments rss Comments rss
Trackback Trackback

Sign up for Newsletter


Categories

Quiz

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

Recent Posts

  • Configuration Error: Could not load type ‘Microsoft.Commerce.Providers.SharePointCommerceOrderModule from assembly because the parent type is sealed
  • How commerce server Site Terms are stored
  • Troubleshoot: An unexpected error has occurred.
  • Design consideration for developing commerce server catalog system
  • Troubleshoot: AuthManager(CommerceServer): Error reading Commerce Server administration database
  • Account Creation Approval Process
  • Troubleshoot: Unauthorized exception when the new user tries to access MyAccount page
  • Microsoft Commerce Server 2009 code name "R2" – January 2010 Community Technical Preview
  • Merchant Access to Catalog Manager
  • Commerce Server 2009 December VPC ready for download

Archives

  • 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 CategoryConfiguration cc_number checkout commerce 7 commerce server commerce server 2002 commerce server 2007 commerce server 2007 Display Types Commerce Server SP2 discounts ecommerce Estimation inventory Kanth Koppala marketing system migration error Mojave 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 .