/// <summary> /// Adds the current market ID as a custom tracking attribute, so that it could /// be used in the Personalization portal e.g. to filter widgets depending on /// the user's market. This is mainly to demonstrate the use of custom attributes, /// it will not automatically affect the tracking or recommendations. /// </summary> /// <param name="trackingData">The tracking data.</param> private void AddMarketAttribute(CommerceTrackingData trackingData) { var currentMarket = _currentMarketService.GetCurrentMarket(); if (currentMarket == null) { return; } trackingData.SetCustomAttribute("MarketId", currentMarket.MarketId.Value); }
private IDictionary <string, IEnumerable <Recommendation> > GetRecommendations(CommerceTrackingData trackingData, HttpContextBase context, IContent content) { var returnValue = new Dictionary <string, IEnumerable <Recommendation> >(); if (_mode == RecommendationsMode.Disabled) { return(returnValue); } var result = _trackingService.Track(trackingData, context, content); if (result == null || _mode == RecommendationsMode.TrackingOnly && context.Request.QueryString["showrecs"] == null) { return(returnValue); } if (result.SmartRecs != null) { foreach (var recommendation in result.SmartRecs) { returnValue.Add(recommendation.Widget, recommendation.Recs.Select(x => new Recommendation(x.Id, _referenceConverter.GetContentLink(x.RefCode)))); } } return(returnValue); }