I've been looking at the https://try.vendr.net/ and I like what I see. It seem's like a very nice shop plugin for Umbraco, there doesn't seem to be a lot of those compared to other CMS'.
Now I've been digging around the plugin trying to figure out how things are made and I'm wondering about something that is kinda crucial to me.
I know my way around code but I'm not a developer.
What I'm wondering about is showing ALL products on a category page. Let me explain:
I have the Category page like the Vendr Demo and my structure is the following:
Categories -> Cars -> BMW, Mercedes, ... -> 3-Serie, 4-serie, 5-serie, ... -> All cars in this model
What I wish to accomplish:
if I go to: Cars category I would like to see ALL BMW and Mercedes cars
if I go to: BMW category I would like to show ALL cars in this
category which is the ones in 3-4-5-serie.
And if I go to the 3-Series I would get all products in this category. This one already works by default. But the two above I don't know how to accomplish
I would greatly appreciate if someone would help me out.
Sure thing. I think I'd probably suggest going via Examine, the search index that comes with Umbraco. I'd probably also suggest installing the Search Extension package by Callum Whyte to make searching a little easier https://github.com/callumbwhyte/umbraco-search-extensions but once installed you could probably do something like the following:
if (_examineManager.TryGetIndex("ExternalIndex", out var index))
{
var searcher = index.GetSearcher();
var query = searcher.CreatePublishedQuery()
.And().NodeTypeAlias(Car.ModelTypeAlias)
.And().Field("path", Model.Id.ToString());
var results = query.Execute().GetResults<Car>();
...
}
Where Car is a Models Builder model for the car type and Model.Id is the current pages ID. So if you run that code on the Cars page it will list all cars, if you run that code on the BMW page it will list all BMW cars, etc, etc.
Show all child products in multiple categories
Hello,
I've been looking at the https://try.vendr.net/ and I like what I see. It seem's like a very nice shop plugin for Umbraco, there doesn't seem to be a lot of those compared to other CMS'.
Now I've been digging around the plugin trying to figure out how things are made and I'm wondering about something that is kinda crucial to me.
I know my way around code but I'm not a developer.
What I'm wondering about is showing ALL products on a category page. Let me explain:
I have the Category page like the Vendr Demo and my structure is the following:
Categories -> Cars -> BMW, Mercedes, ... -> 3-Serie, 4-serie, 5-serie, ... -> All cars in this model
What I wish to accomplish:
I would greatly appreciate if someone would help me out.
Hi Lester,
Sure thing. I think I'd probably suggest going via Examine, the search index that comes with Umbraco. I'd probably also suggest installing the Search Extension package by Callum Whyte to make searching a little easier https://github.com/callumbwhyte/umbraco-search-extensions but once installed you could probably do something like the following:
Where
Car
is a Models Builder model for the car type andModel.Id
is the current pages ID. So if you run that code on theCars
page it will list all cars, if you run that code on theBMW
page it will list all BMW cars, etc, etc.Hope this helps
Matt
Hello,
Thanks for the update and quick reply. I'll be sure to keep an eye on this thread. Looking for the same question for myloweslife.
is working on a reply...