Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

Updating to Episerver Commerce 13 (NodeContent Extensions)

Vote:
 

Hi team,

I have updated my episerver commerce to 13.7.1 version and the NodeContentExtensions class is removed.

In my solution i have used GetCategories() method (from NodeContentExtensions). Can you please suggest me a alternative for this.

Thanks in Advance.

#207264
Edited, Sep 16, 2019 12:11
Vote:
 

It seems it was my bad to remove the entire class. The GetCategories can be reimplemented as below

        private static readonly Lazy<IRelationRepository> _relationRepository = new Lazy<IRelationRepository>(() => ServiceLocator.Current.GetInstance<IRelationRepository>());


/// <summary>
/// Gets the categories to which the category is linked (parent categories).
/// N.B. This does not include the main parent category (given by the ParentLink of the content).
/// </summary>
/// <param name="node">The node.</param>
/// <returns>
/// <see cref="ContentReference" />s of the parent categories.
/// </returns>
public static IEnumerable<ContentReference> GetCategories(this NodeContent node)
{
return GetCategories(node, _relationRepository.Value);
}

/// <summary>
/// Gets the categories to which the category is linked (parent categories).
/// N.B. This does not include the main parent category (given by the ParentLink of the content).
/// </summary>
/// <param name="node">The node.</param>
/// <param name="relationRepository">The relation repository.</param>
/// <returns>
/// <see cref="ContentReference" />s of the parent categories.
/// </returns>
public static IEnumerable<ContentReference> GetCategories(this NodeContent node, IRelationRepository relationRepository)
{
Validator.ThrowIfNull("node", node);
Validator.ThrowIfNull("relationRepository", relationRepository);

return relationRepository.GetParents<NodeRelation>(node.ContentLink).Select(r => r.Parent);
}
#207267
Sep 16, 2019 12:44
nik2911 - Sep 16, 2019 12:55
Thank you so much Quan.. How about the ParseToObject method in PropertyList class(Episerver.Core) ? Is there any alternative
Quan Mai - Sep 16, 2019 12:58
I don't know what you are talking about? which class?
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.