コード例 #1
0
        public GroupCategoryData GetCurrentCategoryData(int portalId, System.Web.HttpRequest request, int entryId = 0, Dictionary <string, string> settings = null, String targetModuleKey = "")
        {
            var defcatid = 0;

            var categoryid = NBrightBuyUtils.GetCategoryIdFromUrl(portalId, request);

            // always use the catid in url if we have no target module (use GetGrpCategory to include properties being listed)
            if ((categoryid > 0) && targetModuleKey == "")
            {
                return(GetGrpCategory(categoryid));
            }

            if (targetModuleKey != "")
            {
                var navigationdata = new NavigationData(portalId, targetModuleKey);
                if (Utils.IsNumeric(navigationdata.CategoryId) && navigationdata.FilterMode)
                {
                    defcatid = Convert.ToInt32(navigationdata.CategoryId);
                }
                // always use the catid in url if we have no navigation categoryid for the target module.
                if ((categoryid > 0) && defcatid == 0)
                {
                    return(GetGrpCategory(categoryid));
                }
            }

            // if we have no catid in url, make sure we have any possible entryid
            if (entryId == 0)
            {
                entryId = NBrightBuyUtils.GetEntryIdFromUrl(portalId, request);
            }

            // use the first/default category the product has
            if (entryId > 0)
            {
                return(GetDefaultCategory(entryId));
            }

            // get any default set in the settings
            if (defcatid == 0)
            {
                if (settings != null && settings["defaultcatid"] != null)
                {
                    var setcatid = settings["defaultcatid"];
                    if (Utils.IsNumeric(setcatid))
                    {
                        defcatid = Convert.ToInt32(setcatid);
                    }
                }
            }

            return(GetGrpCategory(defcatid));
        }