Hi,
Will you have multiple, or just one Category_A node?
This sounds like a perfect place for FindCommerce - its powerful features can solve this with ease.
If using FindCommerce (and then Find in general) is not an option for you, then consider using the Code to find it.
in the worst case IContentLoader/IContentRepository.GetChildren/GetDescendents can be used.
/Q
Hi,
We will only have one Category_A node.
Right now we will not be using Find.
When you write "then consider using the Code to find it" what "Code" are you referring to?
For every NodeContent there is a Code property which is unique and is supposed to be unchanged. The ContentReference might change as it depends on the primary key id in the table, but Code is not.
(Well technically code can be changed but it is usually not the case)
/Q
I see..
Well we want to avoid any hard coded strings, so Code is not the best option for us.
I tried your sugestion with the IContentLoader / Get children:
var categoryA = ContentLoader.GetChildren<CategoryA>(ReferenceConverter.GetRootLink()).FirstOrDefault();
But I can't seem to go from this (which is just a category) to the actual products/variants.
Do you have any suggestions for that?
Honestly I don't understand why it does work for you :).
GetChildren of the Catalog Root Link should return the Catalog(s), not the NodeContent. Yours categoryA should be null.
It should be something like this:
var catalogs = ContentLoader.GetChildren<CatalogContent>(ReferenceConverter.GetRootLink());
foreach (var catalog in catalog)
if
(categoryA !=
null
)
{
var variants = ContentLoader.GetChildren<Variant>(categoryA.ContentLink);
}
If you have only one catalog, you can use First() instead of foreach.
/Q
Hi,
I have a catalog which is structured like this:
Root
Catalog
Category_A
products..
variants..
Category_B
products..
variants..
Where Category_A and Category_B is two created classes
And of course Categoty_B is a public class CategoryB : NodeContent....
Now I want to find all products/variants beloning to only Category_A.
And I do not want to do it using the ID - Because we are in the development stage and it changes from time to time.
My question is: Can I get the content of Category_A using its "type"?? So something along the lines of: through the root link, find all categories of type CategoryA and return these, so that I can search it for products and variants?