Commerce Server Blog

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

Get Discounts for a given Promotion code

ravikanth | April 9, 2009

I want to show the discount applicable for a given promotion coupon code and I feel this is one of the genuine requirement. I tried to play with the API to make this work. If we check back the associations between objects, the coupon code is stored under promotion, the promotions are associated to discounts and discounts are associated to campaign.

Campaign
|
Discount
|
Promotion Code
|
Coupon code

If you check data management object structure, Promotion code and campaigns are easily created and these are associated to a discount.

image

To check which promotion code is assigned to a discount, I think it would be simple. First – get all list of discounts and check for desired promotion code in each discount.

The real trick comes when we want to show the discounts based on the coupon code. I didn’t tried using API but I feel to write a simple script instead of iterating hundreds of discount options. Here is the script that gives the discount name associated for a particular coupon code.

 

Select u_campitem_name
from (
SELECT a.[i_pcdef_id], b.[u_campitem_name]
  FROM [mktg_order_discount] a , [mktg_Campaign_item] b 
WHERE a.i_campitem_id = b.i_campitem_id
and b.[b_campitem_active] = 1
) discounts,

(Select p.[i_pcdef_id], d.[u_pc_code]
from
[mktg_promocode_defn] p , [mktg_promocode] d 
Where p.[i_pcdef_id] = d.[i_pcdef_id]
)
promo
where discounts.[i_pcdef_id] = promo.[i_pcdef_id]
and promo.[u_pc_code] = ‘ABCD1234′

Note: replace “ABCD1234” with your coupon code.

Comments
No Comments »
Categories
Commerce Server 2009, commerce server 2007
Comments rss Comments rss
Trackback Trackback

Error: No content selection context with the name ‘Advertising’ exists for the site ‘MyDefaultSite’

ravikanth | April 3, 2009

After creating blank site using MicrosoftCommerceDefaultSiteNoData.pub file, when I tried to access Advertisements, I am getting following error.

An exception of type ‘Microsoft.Commerce.Providers.Exceptions. InvalidOperationRequestException’ occurred and was caught.

—————————————————————————

03/26/2009 10:29:36

Type : Microsoft.Commerce.Providers.Exceptions. InvalidOperationRequestException, Microsoft.Commerce.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

Message : No content selection context with the name ‘Advertising’ exists for the site ‘MyDefaultSite’. Please see the service configuration file section ServiceConfiguration/Sites/Site[@sitename='MyDefaultSite']/contentSelection for the list of configured selection context names.

Source : Microsoft.Commerce.Providers

Help link :

Data : System.Collections.ListDictionaryInternal

TargetSite : Microsoft.CommerceServer.Runtime.Targeting. ContentSelectionContext  GetSelectionContext(System.String, System.String)

Stack Trace

: at Microsoft.Commerce.Providers.CSHelpers.ContentSelectionHelper. GetSelectionContext(String siteName, String contextName)

at Microsoft.Commerce.Providers.Components.ContentSelectorLoader. ExecuteQuery(CommerceQueryOperation queryOperation,  OperationCacheDictionary operationCache, CommerceQueryOperationResponse response)

at Microsoft.Commerce.Providers.Components.OperationSequenceComponent. Execute(CommerceOperation operation, OperationCacheDictionary  operationCache, CommerceOperationResponse response)

at Microsoft.Commerce.Broker.OperationSequence.ExecuteComponentTree (List`1 executionTreeList, CommerceOperation operation, OperationCacheDictionary operationCache, CommerceOperationResponse response)

at Microsoft.Commerce.Broker.OperationSequence.Execute (CommerceOperation operation)

at Microsoft.Commerce.Broker.MessageHandler. ProcessMessage(String messageHandlerName, CommerceOperation operation)

at Microsoft.Commerce.Broker.OperationService. InternalProcessRequest(CommerceRequest request)

at Microsoft.Commerce.Broker.OperationService. ProcessRequest(CommerceRequest request)

 

Resolution:

We will get this error because of not defining content selection in channel configuration. To fix this issue, open channelconfiguration.config file, add cache for advertising and discounts under <caches> tag and add advertising and discounts to contentselection as shown in the image below.

clip_image002

Comments
No Comments »
Categories
Commerce Server 2009, Troubleshoot
Comments rss Comments rss
Trackback Trackback

Error: StoreObject is not found in the Commerce Server metadata

ravikanth | April 2, 2009

One of my friend was able to unpack csharp site on commerce server 2009 box but when he tries to open the site he was getting following error.

Log Name:      Application
Source:        WCF Service Exception
Date:          3/31/2009 8:52:40 AM
Event ID:      0
Task Category: None
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      VPC-WS2K8-BASE
Description:
An exception of type ‘Microsoft.Commerce.Providers.Metadata.MetadataException’ occurred and was caught.
——————————————————————————————————-
03/31/2009 08:52:40
Type : Microsoft.Commerce.Providers.Metadata.MetadataException, Microsoft.Commerce.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Message : Commerce Server class ‘Microsoft.CommerceServer.Runtime.Profiles.Profile’ or its definition ‘StoreObject’ is not found in the Commerce Server metadata.
Source : Microsoft.Commerce.Providers
Help link :
Data : System.Collections.ListDictionaryInternal
TargetSite : Microsoft.Commerce.Providers.Metadata.CommerceServerEntity GetCommerceServerEntity(System.String, System.String)
Stack Trace :    at Microsoft.Commerce.Providers.Metadata.MergedMetadata.GetCommerceServerEntity(String commerceClassName, String commerceDefinitionName)
   at Microsoft.Commerce.Providers.Metadata.MergedMetadata.CreateMergedMetadata(CommerceEntityDelta repositoryСommerceEntityDelta, EntityMappingDelta repositoryEntityMapping)
   at Microsoft.Commerce.Providers.Metadata.MergedMetadata.MergeMetadata(InheritableCollection`1 repositoryMetadata, MetadataCollection`1 commerceServerMetadata)
   at Microsoft.Commerce.Providers.Metadata.MergedMetadataLoader.GetMergedMetadata(String siteChannelKey, OperationCacheDictionary operationCache)
   at Microsoft.Commerce.Providers.Metadata.MergedMetadataLoader.ExecuteQuery(CommerceQueryOperation queryOperation, OperationCacheDictionary operationCache, CommerceQueryOperationResponse response)
   at Microsoft.Commerce.Providers.Components.OperationSequenceComponent.Execute(CommerceOperation operation, OperationCacheDictionary operationCache, CommerceOperationResponse response)
   at Microsoft.Commerce.Broker.OperationSequence.ExecuteComponentTree(List`1 executionTreeList, CommerceOperation operation, OperationCacheDictionary operationCache, CommerceOperationResponse response)
   at Microsoft.Commerce.Broker.OperationSequence.Execute(CommerceOperation operation)
   at Microsoft.Commerce.Broker.MessageHandler.ProcessMessage(String messageHandlerName, CommerceOperation operation)
   at Microsoft.Commerce.Broker.OperationService.InternalProcessRequest(CommerceRequest request)
   at Microsoft.Commerce.Providers.Utility.CommerceEntityMetadata.ExecuteMetadataQuery(MetadataCacheKey cacheKey, String modelName)
   at Microsoft.Commerce.Providers.Utility.CommerceEntityMetadata.<>c__DisplayClass1.<Get>b__0(MetadataCacheKey cacheKey)
   at Microsoft.Commerce.Application.Common.CachedFactory`2.GetOrCreate(TKey key, CreateInstance`2 factory)
   at Microsoft.Commerce.Providers.Utility.CommerceEntityMetadata.Get(String modelName, Nullable`1 commerceArea)
   at Microsoft.Commerce.Providers.Utility.CatalogConfigurationBuilder.GetMetadata(String modelName, EntityMapping& entityMapping, IEnumerable`1& propertyDefinitions, IEnumerable`1& definitionMappings)
   at Microsoft.Commerce.Providers.Utility.CatalogConfigurationBuilder.GetEntityMapping(String modelName)
   at Microsoft.Commerce.Providers.Components.CatalogLoader.Init(CommerceQueryOperation queryOperation, OperationCacheDictionary operationCache, CommerceQueryOperationResponse response)
   at Microsoft.Commerce.Providers.Components.CatalogLoader.ExecuteQuery(CommerceQueryOperation queryOperation, OperationCacheDictionary operationCache, CommerceQueryOperationResponse response)
   at Microsoft.Commerce.Providers.Components.OperationSequenceComponent.Execute(CommerceOperation operation, OperationCacheDictionary operationCache, CommerceOperationResponse response)
   at Microsoft.Commerce.Broker.OperationSequence.ExecuteComponentTree(List`1 executionTreeList, CommerceOperation operation, OperationCacheDictionary operationCache, CommerceOperationResponse response)
   at Microsoft.Commerce.Broker.OperationSequence.Execute(CommerceOperation operation)
   at Microsoft.Commerce.Broker.MessageHandler.ProcessMessage(String messageHandlerName, CommerceOperation operation)
   at Microsoft.Commerce.Broker.OperationService.InternalProcessRequest(CommerceRequest request)
   at Microsoft.Commerce.Broker.OperationService.ProcessRequest(CommerceRequest request)

 

One thing we should keep in mind that CSharp.pub is for CS2007 and as it is it will not work in CS2009 and this pup does not contains information for “Store Object”, “VirtualEarthConfig” & “TargetingContext”. Commerce Server 2009 has provided a separate pub similar to CSharp.pub. the pub name is “MicrosoftCommerceDefaultSiteNoData.pup” or “MicrosoftCommerceDefaultSiteWithSampleData.pup”. The only difference between these two pubs is the first pub imports only schema and the other one imports schema & data.

If you are developing a new asp.net website on top of CS2009, the new pubs will not create asp.net website for you. In that context we can use Csharp.pub file to create CSharp site only. For that open commerce server manager, right click on applications folder in newly created site and select “Add Application”

image

After selecting pub file, from the selected applications, select “CSharpsite” checkbox and get the asp.net site installed.

clip_image001

Comments
No Comments »
Categories
Commerce Server 2009, Troubleshoot
Comments rss Comments rss
Trackback Trackback

Next Entries »

Sign up for Newsletter


Categories

Quiz

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

Recent Posts

  • RCXml2Resx.exe tool stops working
  • Commerce Server Profile Importer Tool
  • Marketing Web service Exception: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM
  • Download Commerce Server 2009 Help Document
  • Commerce Server 2009 work with SharePoint 2010?
  • Failed to set value for profile property ‘email_address’.
  • ArgumentException: An item with the same key has already been added.
  • Please note that one or more items were removed from your order because the product is no longer sold.
  • How to Avoid Duplicate Orders Numbers in Commerce Server
  • Error: Microsoft.Commerce.Contracts.Faults.ItemDoesNotExistFault

Archives

  • July 2010
  • June 2010
  • May 2010
  • April 2010
  • 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 commerce server commerce server 2007 commerce server manager Commerce Server SP2 discounts ecommerce Estimation Installation inventory Kanth Koppala marketing system migration error Mojave operation components operation sequence Order subsystem 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 .