예제 #1
0
        public PriceCalculationDomainService(
            //IWorkContext workContext,
            IStoreContext storeContext,
            DiscountDomainService discountService,
            CategoryDomainService categoryService,
            ManufacturerDomainService manufacturerService,
            IProductAttributeParser productAttributeParser,
            ProductDomainService productService,
            ICacheManager cacheManager
            , SettingDomainService settingDomainService
            //ShoppingCartSettings shoppingCartSettings,
            //CatalogSettings catalogSettings
            )
        {
            //this._workContext = workContext;
            this._storeContext           = storeContext;
            this._discountService        = discountService;
            this._categoryService        = categoryService;
            this._manufacturerService    = manufacturerService;
            this._productAttributeParser = productAttributeParser;
            this._productService         = productService;
            this._cacheManager           = cacheManager;

            //this._shoppingCartSettings = shoppingCartSettings;
            //this._catalogSettings = catalogSettings;
            _settingDomainService = settingDomainService;
        }
예제 #2
0
        /// <summary>
        /// Get category breadcrumb
        /// </summary>
        /// <param name="category">Category</param>
        /// <param name="categoryService">Category service</param>
        /// <param name="aclService">ACL service</param>
        /// <param name="storeMappingService">Store mapping service</param>
        /// <param name="showHidden">A value indicating whether to load hidden records</param>
        /// <returns>Category breadcrumb </returns>
        public static IList <Category> GetCategoryBreadCrumb(this Category category,
                                                             CategoryDomainService categoryService,
                                                             //IAclService aclService,
                                                             StoreMappingDomainService storeMappingService,
                                                             bool showHidden = false)
        {
            if (category == null)
            {
                throw new ArgumentNullException("category");
            }

            var result = new List <Category>();

            //used to prevent circular references
            var alreadyProcessedCategoryIds = new List <int>();

            while (category != null &&                                        //not null
                   !category.Deleted &&                                       //not deleted
                   (showHidden || category.Published) &&                      //published
                   //(showHidden || aclService.Authorize(category)) && //ACL
                   (showHidden || storeMappingService.Authorize(category)) && //Store mapping
                   !alreadyProcessedCategoryIds.Contains(category.Id))        //prevent circular references
            {
                result.Add(category);

                alreadyProcessedCategoryIds.Add(category.Id);

                category = categoryService.GetCategoryById(category.ParentCategoryId);
            }
            result.Reverse();
            return(result);
        }
예제 #3
0
        /// <summary>
        /// Get formatted category breadcrumb
        /// Note: ACL and store mapping is ignored
        /// </summary>
        /// <param name="category">Category</param>
        /// <param name="categoryService">Category service</param>
        /// <param name="separator">Separator</param>
        /// <param name="languageId">Language identifier for localization</param>
        /// <returns>Formatted breadcrumb</returns>
        public static string GetFormattedBreadCrumb(this Category category,
                                                    CategoryDomainService categoryService,
                                                    string separator = ">>", int languageId = 0)
        {
            string result = string.Empty;

            var breadcrumb = GetCategoryBreadCrumb(category, categoryService, null, true);

            for (int i = 0; i <= breadcrumb.Count - 1; i++)
            {
                var categoryName = breadcrumb[i].Name;
                result = String.IsNullOrEmpty(result)
                    ? categoryName
                    : string.Format("{0} {1} {2}", result, separator, categoryName);
            }

            return(result);
        }