I try to get the product-groups in levels with their conatining products. My idea is: I want to have all product-groups from level 1. Then i want to say: give me all child-product from each first-lefel-group. Here is a little picture, that you know what I mean with "product-groups". There you can see, what's level 1 and what's level 2 for me...!
I use the API from merchello for this. Right now I use the MerchelloHelper()
Here is my test-code for trying to get the products:
MerchelloHelper merchello = new MerchelloHelper();
var allCategories = merchello.Collections.Product.GetAll();
string retValue = "";
foreach (IProductCollection product in allCategories)
{
retValue += "<br>" + product.Name + "<br>";
IEnumerable<IProductContent> children = product.GetProducts();
foreach (IProductContent child in children)
{
retValue += "-->" + child.Name + "<br>";
}
}
My Problem is, that in this example I only get all products and not seperated in levels.
Sorry for the delayed reply - can you check out the ftCatalog.cshtml view in the FastTrack starter and try to find a difference in what you are trying to do ... it's seems to me it is sort of the same thing ...
Merchello - try to get product-groups in levels with their containing products
Hello @all,
I try to get the product-groups in levels with their conatining products. My idea is: I want to have all product-groups from level 1. Then i want to say: give me all child-product from each first-lefel-group. Here is a little picture, that you know what I mean with "product-groups". There you can see, what's level 1 and what's level 2 for me...!
I use the API from merchello for this. Right now I use the MerchelloHelper()
Here is my test-code for trying to get the products:
My Problem is, that in this example I only get all products and not seperated in levels.
I hope someone can help me with that!
Thanks!
Hi Jeremias,
You should get the root level collections (instead of all collections) and then use the tree methods ...
Hi Rusty,
Thank you for your answer.
This is my test-code I use now. I have only one Problem with this: I only get the Child-Elements from one of the root-Collections:
And here the output on the webpage:
Like you can see: Only from my root-collection "T-Shirts" I get the "children". When I only use
I only get the children of my T-Shirt-collection for every root-collection:
I know, my output is just for testing - but I hope it shows you what I mean!
Thanks for your help!
Hey Jeremias,
Sorry for the delayed reply - can you check out the
ftCatalog.cshtml
view in the FastTrack starter and try to find a difference in what you are trying to do ... it's seems to me it is sort of the same thing ...Here is the view:
https://github.com/Merchello/Merchello/blob/merchello-dev/src/Merchello.FastTrack.Ui/Views/ftCatalog.cshtml
The model is just passed on via the Models builder, so the property editor. If you need to see how that works, it's here:
https://github.com/Merchello/Merchello/blob/merchello-dev/src/Merchello.Web/PropertyConverters/ProductCollectionValueConverter.cs#L64
is working on a reply...