Adding Image to Profile Sub-System
ravikanth | July 25, 2008Commerce 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.
5. Click on General Information and click on Add Property and add values as shown in the image below.
6. In your registration page, add a input field of type file.
7.
|
// Reading file content.
Stream s = File.OpenRead(filePath); //Creating an user profile. Profile userProfile = profileContext.CreateProfile(newId.ToString(), “UserObject”); |
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).