/// <summary>
        /// Gets the cache provider
        /// </summary>
        /// <returns>the cahce provider</returns>
        private static ICacheProvider GetCacheProvider()
        {
            var cacheProvider = ContextTypeLoader.GetCacheProvider(Infrastructure.Constants.CommerceConstants.KnownCacheNames.CommerceCartCache);

            Assert.IsNotNull(cacheProvider, "cacheProvider");

            return(cacheProvider);
        }
        /// <summary>
        /// Checks to see if there is a catalog item that maps to the current id
        /// </summary>
        /// <param name="itemId">The ID of the catalog item.</param>
        /// <param name="catalogName">The name of the catalog that contains the catalog item.</param>
        /// <param name="isProduct">Specifies whether the item is a product.</param>
        /// <returns>An item if found, otherwise null</returns>
        public static Item ResolveCatalogItem(string itemId, string catalogName, bool isProduct)
        {
            Item foundItem = null;

            // If we make it here, the right route was used, but might have an empty value
            if (!string.IsNullOrEmpty(itemId))
            {
                var            cachekey      = "FriendlyUrl-" + itemId + "-" + catalogName;
                ICacheProvider cacheProvider = ContextTypeLoader.GetCacheProvider(CommerceConstants.KnownCacheNames.FriendlyUrlsCache);
                var            id            = cacheProvider.GetData <ID>(CommerceConstants.KnownCachePrefixes.Sitecore, CommerceConstants.KnownCacheNames.FriendlyUrlsCache, cachekey);

                if (ID.IsNullOrEmpty(id) || id == ID.Undefined)
                {
                    if (isProduct)
                    {
                        foundItem = SearchNavigation.GetProduct(itemId, catalogName);
                    }
                    else
                    {
                        foundItem = SearchNavigation.GetCategory(itemId, catalogName);
                    }

                    if (foundItem != null)
                    {
                        cacheProvider.AddData <ID>(CommerceConstants.KnownCachePrefixes.Sitecore, CommerceConstants.KnownCacheNames.FriendlyUrlsCache, cachekey, foundItem.ID);
                    }
                    else
                    {
                        cacheProvider.AddData <ID>(CommerceConstants.KnownCachePrefixes.Sitecore, CommerceConstants.KnownCacheNames.FriendlyUrlsCache, cachekey, ID.Undefined);
                    }
                }
                else if (id != ID.Undefined && id != ID.Null)
                {
                    foundItem = Context.Database.GetItem(id);
                }
            }

            return(foundItem);
        }