/// <summary> /// Get localized property of an <see cref="ICategoryNode"/> instance /// </summary> /// <param name="node">Node</param> /// <param name="keySelector">Key selector</param> /// <returns>Localized property</returns> public static LocalizedValue <string> GetLocalized(this ICategoryNode node, Expression <Func <ICategoryNode, string> > keySelector) { return(GetLocalizedEx( node, "Category", LocaleKeyFromExpression(keySelector.Body), x => keySelector.Compile().Invoke(x), EngineContext.Current.Resolve <IWorkContext>().WorkingLanguage)); }
/// <summary> /// Get localized property of an <see cref="ICategoryNode"/> instance /// </summary> /// <param name="node">Node</param> /// <param name="keySelector">Key selector</param> /// /// <param name="language">Language</param> /// <returns>Localized property</returns> public static LocalizedValue <string> GetLocalized(this ICategoryNode node, Expression <Func <ICategoryNode, string> > keySelector, Language language) { return(GetLocalizedEx( node, "Category", LocaleKeyFromExpression(keySelector.Body), x => keySelector.Compile().Invoke(x), language)); }
/// <summary> /// Get localized property of an <see cref="ICategoryNode"/> instance /// </summary> /// <param name="node">Node</param> /// <param name="keySelector">Key selector</param> /// /// <param name="languageId">Language identifier</param> /// <returns>Localized property</returns> public static LocalizedValue <string> GetLocalized(this ICategoryNode node, Expression <Func <ICategoryNode, string> > keySelector, int languageId) { return(GetLocalizedEx( node, "Category", LocaleKeyFromExpression(keySelector.Body), x => keySelector.Compile().Invoke(x), EngineContext.Current.Resolve <ILanguageService>().GetLanguageById(languageId))); }
/// <summary> /// Get localized property of an <see cref="ICategoryNode"/> instance /// </summary> /// <param name="node">Node</param> /// <param name="keySelector">Key selector</param> /// <returns>Localized property</returns> public static LocalizedValue <string> GetLocalized(this ICategoryNode node, Expression <Func <ICategoryNode, string> > keySelector) { Guard.NotNull(node, nameof(node)); return(GetLocalizedEx( node, "Category", node.Id, keySelector, EngineContext.Current.Resolve <IWorkContext>().WorkingLanguage)); }
/// <summary> /// Get localized property of an <see cref="ICategoryNode"/> instance /// </summary> /// <param name="node">Node</param> /// <param name="keySelector">Key selector</param> /// /// <param name="language">Language</param> /// <returns>Localized property</returns> public static LocalizedValue <string> GetLocalized(this ICategoryNode node, Expression <Func <ICategoryNode, string> > keySelector, Language language) { var invoker = keySelector.CompileFast(); return(EngineContext.Current.Resolve <LocalizedEntityHelper>().GetLocalizedValue( node, "Category", invoker.Property.Name, (Func <ICategoryNode, string>)invoker, language)); }
/// <summary> /// Get localized property of an <see cref="ICategoryNode"/> instance /// </summary> /// <param name="node">Node</param> /// <param name="keySelector">Key selector</param> /// /// <param name="language">Language</param> /// <returns>Localized property</returns> public static LocalizedValue <string> GetLocalized(this ICategoryNode node, Expression <Func <ICategoryNode, string> > keySelector, Language language) { Guard.NotNull(node, nameof(node)); return(GetLocalizedEx( node, "Category", node.Id, keySelector, language)); }
/// <summary> /// Get localized property of an <see cref="ICategoryNode"/> instance /// </summary> /// <param name="node">Node</param> /// <param name="keySelector">Key selector</param> /// /// <param name="languageId">Language identifier</param> /// <returns>Localized property</returns> public static LocalizedValue <string> GetLocalized(this ICategoryNode node, Expression <Func <ICategoryNode, string> > keySelector, int languageId) { Guard.NotNull(node, nameof(node)); return(GetLocalizedEx( node, "Category", node.Id, keySelector, EngineContext.Current.Resolve <ILanguageService>().GetLanguageById(languageId))); }
/// <summary> /// Get search engine name for a category node /// </summary> /// <param name="node">Node</param> /// <returns>Search engine name</returns> public static string GetSeName(this ICategoryNode node) { Guard.NotNull(node, nameof(node)); return(GetSeName( "Category", node.Id, EngineContext.Current.Resolve <IWorkContext>().WorkingLanguage.Id, EngineContext.Current.Resolve <IUrlRecordService>(), EngineContext.Current.Resolve <ILanguageService>())); }
/// <summary> /// Get localized property of an <see cref="ICategoryNode"/> instance /// </summary> /// <param name="node">Node</param> /// <param name="keySelector">Key selector</param> /// /// <param name="languageId">Language identifier</param> /// <returns>Localized property</returns> public static LocalizedValue <string> GetLocalized(this ICategoryNode node, Expression <Func <ICategoryNode, string> > keySelector, int languageId) { var invoker = keySelector.CompileFast(); return(EngineContext.Current.Scope.ResolveOptional <LocalizedEntityHelper>()?.GetLocalizedValue( node, node.Id, nameof(Category), invoker.Property.Name, (Func <ICategoryNode, string>)invoker, languageId) ?? new LocalizedValue <string>(invoker.Invoke(node))); }
public virtual IEnumerable <ICategoryNode> GetCategoryTrail(ICategoryNode node) { Guard.NotNull(node, nameof(node)); var treeNode = GetCategoryTree(node.Id, true); if (treeNode == null) { return(Enumerable.Empty <ICategoryNode>()); } return(treeNode.Trail .Where(x => !x.IsRoot) //.TakeWhile(x => x.Value.Published) // TBD: (mc) do we need this? .Select(x => x.Value)); }
/// <summary> /// Builds a category breadcrumb (path) for a particular category node /// </summary> /// <param name="categoryNode">The category node</param> /// <param name="languageId">The id of language. Pass <c>null</c> to skip localization.</param> /// <param name="withAlias"><c>true</c> appends the category alias - if specified - to the name</param> /// <param name="separator">The separator string</param> /// <returns>Category breadcrumb path</returns> public static string GetCategoryPath(this ICategoryNode categoryNode, ICategoryService categoryService, int?languageId = null, string aliasPattern = null, string separator = " » ") { Guard.NotNull(categoryNode, nameof(categoryNode)); var treeNode = categoryService.GetCategoryTree(categoryNode.Id, true); if (treeNode != null) { return(categoryService.GetCategoryPath(treeNode, languageId, aliasPattern, separator)); } return(string.Empty); }
public virtual async Task <string> GetCategoryPathAsync( ICategoryNode categoryNode, int?languageId = null, string aliasPattern = null, string separator = " » ") { Guard.NotNull(categoryNode, nameof(categoryNode)); var treeNode = await GetCategoryTreeAsync(categoryNode.Id, true); if (treeNode != null) { return(GetCategoryPath(treeNode, languageId, aliasPattern, separator)); } return(string.Empty); }
/// <summary> /// This method is invoked before a Category Node is deleted /// </summary> /// <param name="category">The Category Node to be deleted</param> /// <param name="session">The session that must be used to perform tasks on additional objects</param> /// <remarks>When this action is invoked, none of the object involved were saved to Content Store yet.</remarks> public void OnBeforeCategoryDelete(ICategoryNode category, IUserWriteSession session) { }
/// <summary> /// This method is invoked after a Category Node was deleted /// </summary> /// <param name="category">The Category Node that was deleted</param> /// <param name="session">The session that must be used to perform tasks on additional objects</param> /// <remarks>When this action is invoked, none of the object involved were saved to Content Store yet.</remarks> public void OnAfterCategoryDelete(ICategoryNode category, IUserWriteSession session) { }
/// <summary> /// This method is invoked after a Category Node was created. /// DO NOT assign to CategoryNode.Name in thid method, otherwise it will cause infinite loop /// </summary> /// <param name="category">The Category Node that was renamed</param> /// <param name="session">The session that must be used to perform tasks on additional objects</param> /// <remarks>When this action is invoked, none of the object involved were saved to Content Store yet.</remarks> public void OnCategoryRenamed(string oldName, string newName, ICategoryNode category, IUserWriteSession session) { }
/// <summary> /// This method is invoked after a Category Node was created /// </summary> /// <param name="category">The Category Node that was created</param> /// <param name="session">The session that must be used to perform tasks on additional objects</param> /// <remarks>When this action is invoked, none of the object involved were saved to Content Store yet.</remarks> public void OnCategoryCreated(ICategoryNode category, IUserWriteSession session) { }
public static string GetActiveSlug(this ICategoryNode node) { Guard.NotNull(node, nameof(node)); return(EngineContext.Current.Scope.ResolveOptional <LocalizedEntityHelper>()?.GetActiveSlug(nameof(Category), node.Id, null)); }
public static string GetSeName(this ICategoryNode node) { Guard.NotNull(node, nameof(node)); return(EngineContext.Current.Resolve <LocalizedEntityHelper>().GetSeName("Category", node.Id, null)); }