Commerce Server 2009
Commerce server foundation supports four types of operations. They are
- CommerceQuery
- CommerceCreate,
- CommerceUpdate
- CommerceDelete
CommerceQuery operation is used to fetch data from commerce server. These operations can be performed on the root level or top level entity (such as Catalog, Basket, Product, etc). If you want to manipulate data of related entities then you should use CommerceRelatedOperations. We will discuss more about the other operations in the upcoming articles.
So, CommerceQuery operation can be used to query
- Existing Commerce Entities
- Existing Commerce Related Entities
- Existing Relationships
In the below example, we are fetching product information and their variants information also
|
// First construct a CommerceQuery<> object. The first parameter to the generic class identifies the commerce entity type. var productQuery = new CommerceQuery<CommerceEntity>("Product"); // Provide the search criteria to identify the product and the catalog to look in productQuery.SearchCriteria.Model.Properties["CatalogId"] = "Adventure Works Catalog"; productQuery.SearchCriteria.Model.Id = "AW200-12"; // Request the properties to be returned for the product productQuery.Model.Properties.Add("Id"); productQuery.Model.Properties.Add("DisplayName"); productQuery.Model.Properties.Add("Description"); productQuery.Model.Properties.Add("ListPrice"); // Construct a CommerceQueryRelatedItem operation to query the variants of the product { var queryVariants = new CommerceQueryRelatedItem<CommerceEntity>("Variants", "Variant"); // The following requests that the results be sorted, in order, by colour and returned from the first element. queryVariants.SearchCriteria.SortProperties = new List<CommerceSortProperty>(); queryVariants.SearchCriteria.SortProperties.Add(new CommerceSortProperty("Variant", "ProductColor", SortDirection.Ascending)); queryVariants.SearchCriteria.FirstItemIndex = 0; queryVariants.SearchCriteria.ReturnTotalItemCount = true; // Request the properties to be returned for the variants queryVariants.Model.Properties.Add("Id"); queryVariants.Model.Properties.Add("VariantCode"); queryVariants.Model.Properties.Add("ProductColor"); productQuery.RelatedOperations.Add(queryVariants); } CommerceRequestContext context = new CommerceRequestContext();
CommerceQueryOperationResponse response = OperationService.ProcessRequest(context, productQuery.ToRequest()).OperationResponses[0] as CommerceQueryOperationResponse; |
If you like this post, please click on our sponsor advertisement.
Here are some thoughts on how can we create generic commerce server platform where we can onboard multiple brands easily (like samsung.commerceserverguru.com, lg.commerceserverguru.com, etc). Some assumptions made are..
- There will be one commerce server site and I provides one (virtual) catalog for each brand.
- There can be multiple web channels (sub sites – each subsite will get get one channel ).
The first thing its strike our minds is the configuration changes. We have two configurations, one is application configuration and the other is business process configuration. These things will be different from one website to another website. In total, our configuration points are
- Pipelines: Will leverage out of box pipelines but if the business process are different then we will created different pipelines for each brand and the same will get reflect in the channel configuration.
- Channelconfiguration: If business process are different, its better we create different channel for each site and this channel name is provided in the ChannelConfiguration list (in the site).
- Metadata xml file: this can be the same for all website as the code base/structure is same.
- Web.config (Appsettings) - Since the configuration will differ from site to site, recommending to keep them in SharePoint Property Bag (It is a hash table where we are able to accumulate key and values).
First, I have created two CS applications on two different root site collections (same web application). The first site collection name is etv & second site collection name is mtv(Both points to different CS sites). Next, I have created a new channel in channel configuration (as shown below).
If we open the webpage, you will see wired exception and following exception is logged in the event viewer.
In order to fix this issue, I have added new site information at <Sites> section.
| <Sites> <Site sitename="etv" disableProductVersionHttpHeader="true" metadataRepositoryPath="c:\inetpub\wwwroot\wss\VirtualDirectories\cssite\MetadataDefinitions.xml> </Site> <Site sitename="mtv" disableProductVersionHttpHeader="true" metadataRepositoryPath="c:\inetpub\wwwroot\wss\VirtualDirectories\cssite\MetadataDefinitions.xml> </Site> </Sites> |
When web page opened, you will receive different exception in the event viewer.
Changing the useSharedCommerceContexts=false in channelconfiguration will not work . A value of true indicates that CommerceContext.Current will be available, and used by all operation sequence components. Context objects exposed through the CommerceSiteContexts class will refer back to the context objects exposed through CommerceContext.Current. This also means that only a single site can be configured in ChannelConfiguration.config. A value of false indicates that CommerceContext.Current will be null, and not used by any operation sequence components. A separate set of Commerce Server context objects will be created for each site configured in ChannelConfiguration.config. These can be accessed through the CommerceSiteContexts class.
Note: As of now, commerce server 2009 allows us to point to single CS site from a web application. This is fixed in CS2009 R2.
Final option is to provide the same commerce server site name for both site collections in the channelconfiguration. After doing below changes the site is working fine.
<Channel sitename="etv" name="mtv">
<MessageHandlers>
<MessageHandler ………….
Here are my findings/recommendations.
- For each site collection(brand), we will create different channel (if required), or leverage default channel.
- Try to leverage existing pipelines – on demand we will create new pipelines for the brands. The same has to be reflected in channelconfiguration (under channels).
- Metadata xml file is mapped to a CS site so this configuration will be common for all brands.
White labeling is still a myth using commerce server 2009 but my thought process is how can we reduce the development efforts to make this happen (if not self serviced site creation). If you have any queries or suggestions, please do drop me an email.
If you like this post, please click on our sponsor advertisement.
We have couple of servers in the commerce server farm. After installing commerce server, when we try to configure it, we encounter a strange error in configuration process. It says “The DirectMailer Resource is already configured on another computer. Only one Direct Mailer resource is supported per deployment). On OK button click, the configuration process roll backs the configuration process.
Marketing direct mailer can be installed only on one server in the farm. To avoid this error, I figured out couple of options.
Option 1: Open command prompt. Navigate to “c:\Program Files (x86)\Microsoft Commerce Server 2007\” folder and run below command.
Run CSConfig /r Feature.MS.CS.Server
This will reconfigure only the admin database (not the direct mailer nor staging – other available features are Feature.MS.CS.DirectMailer, Feature.MS.CS.PCW, Feature.MS.CS.CsStaging and Feature.MS.CS.HealthMonitoring).
or
Option 2. From the existing commerce server site, delete direct mailer resource (from commerce server manager) and run below command.
Run CSConfig /f
This will reconfigure only the admin database (not the direct mailer nor staging.).
I opted second option and it worked for me.
If you like this post, please click on our sponsor advertisement.
We have production site and staging site in different IIS servers. Last week, we have a production issue where we are facing issue in pushing the data from staging server to production server (where it was working before). In the event log, we see below exception.
Failed to export business data for ‘Catalog’ resource for project ‘PushData2Prod’.
Cannot open database "MSCS_Admin" requested by the login.
We figured out that it is happening because the staging service is attempting to connect to MSCS_Admin database using anonymous. After troubleshooting, we figured out that the staging service is running in Network service rather than domain account. Running the service under network account is attempting to the connect to the database anonymously. After making the service run under the domain account the staging service started working fine and we are able to push the data from staging server to production server.
The domain account to the service is normally set when running the configuration wizard after the installation of Commerce Server. It is important to note that you must also re-run the configuration tool after installing Commerce Server service packs . Mostly we might of missed this.
If you like this post, please click on our sponsor advertisement.
We have production site and staging site in different IIS servers. Last week, we have a production issue where we are facing issue in pushing the data from staging server to production server (where it was working before). In the event log, we see below exception.
Failed to export business data for ‘Catalog’ resource for project ‘PushData2Prod’.
Cannot open database "MSCS_Admin" requested by the login.
We figured out that it is happening because the staging service is attempting to connect to MSCS_Admin database using anonymous. After troubleshooting, we figured out that the staging service is running in Network service rather than domain account. Running the service under network account is attempting to the connect to the database anonymously. After making the service run under the domain account the staging service started working fine and we are able to push the data from staging server to production server.
The domain account to the service is normally set when running the configuration wizard after the installation of Commerce Server. It is important to note that you must also re-run the configuration tool after installing Commerce Server service packs . Mostly we might of missed this.
If you like this post, please click on our sponsor advertisement.
