我正在尝试使用Microsoft Commerce Server服务器端代码检索折扣的开始和结束日期。如何才能做到这一点?我唯一被卡住的数据是促销代码"TEST“。关于如何创建折扣对象或CampaignItem对象并设置促销代码以检索其属性,没有太多的代码示例。请帮帮忙。
发布于 2013-07-24 04:43:47
下面的代码片段演示了如何获取Commerce Server Discount的StartDate和EndDate。这里假设您使用的是Commerce Server 2007 API,并且您知道要从中获取日期的折扣的ID。
//The discount id we want to get dates from.
var discountId = 12;//Set to your ID.
//Configure the Commerce Server site name.
var siteName = "StarterSite";
//We need a MarketingContext instance so we can access the marketing API.
var mc = MarketingContext.Create(siteName, null, AuthorizationMode.NoAuthorization);
//Get our discount.
var discount = (Discount)mc.CampaignItems.GetCampaignItem(discountId);
//Voila. Start and End dates.
var startDate = discount.StartDate;
var endDate = discount.EndDate;注意: API重载返回一个MarketingContext实例,该实例在本地模式下使用营销系统管理MarketingContext.Create。有关这些模式的详细信息,请参阅Understanding the Different Types of Commerce Server APIs。
https://stackoverflow.com/questions/17533099
复制相似问题