How do i use UIHint.CatalogContent ( Commerce 8.11.4 )

Vote:
 

Hi

I have a CMS page with a property, the property looks like this:

[CultureSpecific]
[UIHint(EPiServer.Commerce.UIHint.CatalogContent)]
[Display(Name = "Product catalog",
Description = "Product category parent referense",
GroupName = SystemTabNames.Content)]
public virtual ContentReference ProductCatalogReferense { get; set; }

And I want to get all the sub categories in that catalog.

I have try:

var categoryList = catalog.GetCatalogNode(CurrentPage.ProductCategoryReferense.ID);

But its getting null

The thing is I dont know how to use "UIHint.CatalogContent"

Does someone have any idea?

#121943
May 21, 2015 11:01
Vote:
 

Hi again

After a lot of testing i got this to work.

Here is the code...

IContentLoader contentLoader = ServiceLocator.Current.GetInstance<IContentLoader>();

var referenceConverter = ServiceLocator.Current.GetInstance<ReferenceConverter>();

var myCatalog = contentLoader.GetChildren<CatalogContent>(referenceConverter.GetRootLink()).FirstOrDefault(x => x.ContentLink.Equals(CurrentPage.ProductCategoryReferense));

ICatalogSystem catalog = ServiceLocator.Current.GetInstance<ICatalogSystem>();

var nodes = catalog.GetCatalogNodes(myCatalog.CatalogId);

I hope this help anyone...

#121945
May 21, 2015 13:04
Vote:
 

Hi,

I would suggest to do this:

IContentLoader contentLoader = ServiceLocator.Current.GetInstance<IContentLoader>();

var nodeContents = contentLoader.GetChildren<NodeContent>(CurrentPage.ProductCategoryReferense);

Regards,

/Q

#121953
May 21, 2015 15:29
* 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.