First of all congrats for this great piece software.
Second, how can I add a product to multiple categories? or what structure should I have to support a scenario like this, because the Bazar example has a product per category.
The structure I think is best for this scenario looks like:
So that you don't wind up with duplicate content penalties, putting all of the products under a single node and then either associate the product with the categories using an MNTP or something.
How many products do you see yourself dealing with?
I have 200+ products with different options (color, perfume, packing ...).
The issue I'm having is how I associate the product with categories? Do I use a multinode content picker? My problem is not with Merchello (I think), but with Umbraco: how do I query products that have the current cateogry associated. The multinode picker returns content ids separated by a comma.
If I've understood right you have a category document type with a picker for products on it, and so you can split those comma seperated Ids and turn them into full IPublishedContent instances using Umbraco.TypedContent(id).
Or, probably better, install Umbraco Core Property Value Converters with which you'll find that you can get back an IEnumerable<IPublishedContent> directly.
It's actually the other way around. The product has a category picker. So when I display a category i should get all the products that have this category assigned. But your solution sounds a lot easier.
After some digging I managed to get the products assigned to a category like this:
var productContainerId = 1063; // the 'Products' parent node var categoryId = page.Id.ToString(); // the current 'Category' node Id var products = Umbraco.TypedContent(productContainerId).Children.Where(p => p.GetPropertyValue("category").Contains(categoryId)); // get all children of the 'Products' node where the MNTP property 'category' contains the 'Category' node id
What I don't know is how will this perform in a high traffic website. But until then let's hope it does well.
Tom's Examine implementation did not work and I don't know why and I haven't tried to know why. I've impemented the 'GatheringNodeData' event in a derived class from 'ApplicationBase', but the query didn't return rows.
Should be OK - everything you are doing looks to be within the Umbraco content cache, you aren''t hitting the database.
Just to note though, it's possible you'd find your queries is returing some false positives. If say you were looking for a category with Id of 1000, it would match one against category 10000 (given it's a string match). Quite unlikely and you'd need a lot of nodes of course(!), but might be safer to do p.GetPropertyValue("category").Split(',').Contains(categoryId); You may also need to check for null too, not sure (if an empty string is returned with no categories selected, might not be needed).
Product in multiple Categories
Hi,
First of all congrats for this great piece software.
Second, how can I add a product to multiple categories? or what structure should I have to support a scenario like this, because the Bazar example has a product per category.
The structure I think is best for this scenario looks like:
So that you don't wind up with duplicate content penalties, putting all of the products under a single node and then either associate the product with the categories using an MNTP or something.
How many products do you see yourself dealing with?
I have 200+ products with different options (color, perfume, packing ...).
The issue I'm having is how I associate the product with categories? Do I use a multinode content picker? My problem is not with Merchello (I think), but with Umbraco: how do I query products that have the current cateogry associated. The multinode picker returns content ids separated by a comma.
If I've understood right you have a category document type with a picker for products on it, and so you can split those comma seperated Ids and turn them into full IPublishedContent instances using Umbraco.TypedContent(id).
Or, probably better, install Umbraco Core Property Value Converters with which you'll find that you can get back an IEnumerable<IPublishedContent> directly.
Hope that helps
Andy
It's actually the other way around. The product has a category picker. So when I display a category i should get all the products that have this category assigned. But your solution sounds a lot easier.
Thanks!
Hey Daniel, I've done this before using examine to query the products by category. below is the two snippets of code if it helps :)
Querying:
OnGatheringNodeData Event to make the MNTP searchable:
Hope this helps.
Cheers,
Tom
Hi all,
Thanks for all your help.
After some digging I managed to get the products assigned to a category like this:
What I don't know is how will this perform in a high traffic website. But until then let's hope it does well.
Tom's Examine implementation did not work and I don't know why and I haven't tried to know why. I've impemented the 'GatheringNodeData' event in a derived class from 'ApplicationBase', but the query didn't return rows.
Should be OK - everything you are doing looks to be within the Umbraco content cache, you aren''t hitting the database.
Just to note though, it's possible you'd find your queries is returing some false positives. If say you were looking for a category with Id of 1000, it would match one against category 10000 (given it's a string match). Quite unlikely and you'd need a lot of nodes of course(!), but might be safer to do p.GetPropertyValue("category").Split(',').Contains(categoryId); You may also need to check for null too, not sure (if an empty string is returned with no categories selected, might not be needed).
Cheers
Andy
Thanks, but apparently the
gives an error.
Eighter I forgot how to use 'Where' or there's something i'm missing. If I omit the 'Split' method then all works.
Later edit:
And I spoke to soon...
Don't know why but
is not the same as
is working on a reply...