If you followed the last post you now have a brand new DisplayTemplate on the marketing system with three properties: ProductImage, ProductTitle and ProductPrice.
Before creating new advertisements and associate the new DisplayTemplate we will need an expression. This expression will be used to filter only advertisements for a determined display window.
To do that, we need two steps:
Step 1
Step 2
Great. Now we have a new TargetingContext property. It's time to create a new global expression. This expression will be associated to the advertisement and will be used during the content selection to filter only advertisements fitting to our display window.
The following code can be used on a Console Application to create the appropriate global expression:
using System;using System.Collections.Generic;using System.Text;
using Microsoft.CommerceServer;using Microsoft.CommerceServer.Marketing;using System.Xml;
namespace CreateGlobalExpression{ class Program { static void Main(string[] args) { // Set the URL to the Web service. string marketingWebServiceUrl = @"http://localhost/MarketingWebService/MarketingWebService.asmx"; // Create an instance of the Marketing System agent. MarketingServiceAgent ma = new MarketingServiceAgent(marketingWebServiceUrl); MarketingContext marketingSystem = MarketingContext.Create(ma);
//Creating the global expression XmlDocument xmlDoc = new XmlDocument(); XmlElement clause = xmlDoc.CreateElement("CLAUSE"); clause.SetAttribute("OPER", "equal");
XmlElement property = xmlDoc.CreateElement("PROPERTY"); property.SetAttribute("ID", "TargetingContext.BillBoard"); property.SetAttribute("TYPE", "STRING");
XmlElement immedval = xmlDoc.CreateElement("IMMED-VAL"); immedval.SetAttribute("TYPE", "STRING");
XmlElement value = xmlDoc.CreateElement("VALUE"); value.InnerText = "MainDisplayWindow";
immedval.AppendChild(value); clause.AppendChild(property); clause.AppendChild(immedval);
// Create a new expression. Expression ex = marketingSystem.Expressions.NewExpression(false); ex.Description = "BillBoard Select Expression"; ex.Body = clause; ex.Name = "BillBoard"; ex.Category = "TargetCondition"; ex.Save(true);
} }}
The attachment has a zip file with a console application to create the expression.
See you later, Cris.
This posting is provided "AS IS" with no warranties, and confers no rights.