Example #1
0
        /// <summary>
        /// Handles the OnClick event of the btnLogOut control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void btnLogOut_OnClick(object sender, EventArgs e)
        {
            ICustomerManager <CustomerInfo> customerManager = Sitecore.Ecommerce.Context.Entity.Resolve <ICustomerManager <CustomerInfo> >();

            AnalyticsUtil.AuthentificationUserLoggedOut(customerManager.CurrentUser.NickName);

            AuthenticationManager.Logout();

            customerManager.ResetCurrentUser();

            var url = string.Empty;

            if (Sitecore.Context.Item.Security.CanRead(User.Current))
            {
                var qs = WebUtil.GetQueryString();

                var itemUrl = Sitecore.Context.ClientData.GetValue("itempath") as string;
                if (string.IsNullOrEmpty(itemUrl))
                {
                    url = LinkManager.GetItemUrl(Sitecore.Context.Item);
                }
                else
                {
                    VirtualProductResolver virtualProductResolver = Sitecore.Ecommerce.Context.Entity.Resolve <VirtualProductResolver>();
                    var folderItem = virtualProductResolver.ProductCatalogItem;
                    if (folderItem != null)
                    {
                        url = virtualProductResolver.GetVirtualProductUrl(folderItem, Sitecore.Context.Item);
                    }
                }

                qs  = qs.TrimStart('?');
                qs  = (qs != string.Empty) ? "?" + qs : string.Empty;
                url = string.Concat(url, qs);
            }
            else
            {
                url = "/";
            }

            Response.Redirect(url);
        }
Example #2
0
        /// <summary>
        /// Gets the virtual product URL with analitics query string.
        /// </summary>
        /// <param name="productItem">The product item.</param>
        /// <returns>The virtual product URL with analitics query string.</returns>
        public virtual string GetVirtualProductUrlWithAnaliticsQueryString(Item productItem)
        {
            Assert.ArgumentNotNull(productItem, "productItem");

            VirtualProductResolver virtualProductResolver = Context.Entity.Resolve <VirtualProductResolver>();
            Item catalogItem = virtualProductResolver.ProductCatalogItem;

            if (catalogItem == null)
            {
                Log.Warn("Product catalog item is null", this);
                return(string.Empty);
            }

            string virtualProductUrl = virtualProductResolver.GetVirtualProductUrl(catalogItem, productItem);

            if (string.IsNullOrEmpty(virtualProductUrl))
            {
                Log.Warn("Fail to get virtual product URL", this);
                return(string.Empty);
            }

            return(this.navigationEvents.AddFollowListToQueryString(virtualProductUrl, catalogItem.Name));
        }