Example #1
0
        public void OnResolvedPage(System.Web.Mvc.ControllerContext controllerContext, CMS.Sites.View.PageRequestContext pageRequestContext)
        {
            var page = pageRequestContext.Page;
            if (!page.CustomFields.ContainsKey("ProductId"))
            {
                return;
            }

            var value = ParameterizedFieldValue.GetFieldValue(page.CustomFields["ProductId"], pageRequestContext.GetValueProvider());
            if (String.IsNullOrEmpty(value))
            {
                return;
            }

            int productId;
            if (Int32.TryParse(value, out productId))
            {
                BehaviorReceivers.Receive(Site.Current.GetCommerceInstanceName(),
                            new Behavior
                            {
                                Type = BehaviorTypes.View,
                                ItemId = productId.ToString(),
                                UserId = controllerContext.RequestContext.HttpContext.EnsureVisitorUniqueId()
                            });
            }
        }