Auto select product type based on taxonomy term (category)
Let's say we have a Commerce webshop with two product types: Default and Wine. There are many categories(bread, water, wine, nuts, ....) in which the products are defined, and all categories but Wine can use the default product type.
To illustrate the problem along with the text below:
http://puu.sh/2FBzH.png
What I want to do is allow my client to select which category he wants to create a product in, and have Drupal automatically create a creation form for the appropiate product type. So if the client chooses the Wine category, the Wine product type is selected. If the client chooses the Nuts or Bread category it selects the Default product type.
It would be possible to manually solve this problem by creating tons of duplicates of the "Default" product type with the exact same fields but a default taxonomy term chosen, but because of the large scale of this webshop it would take tons of work if a new field would have to be added to the default product type later.
The Inline Entity form module has provided me with the option of creating a new node("add content") of the Product node type and also generate a Commerce product with that, but I want to make it even simpler for the client by having the Inline Entity Form automatically choose the correct product type depending on the taxonomy term("category") chosen. Any idea how this can be done?
Suggestions of taking a completely different approach to this problem are also welcome.
Thanks!
Comments
Your solution is definitely a good way to be able to group products of multiple PVTs. For my needs it's not so suitable because the store needs to be quickly adapted to change. I don't like having to choose PVTs to show products in a specific category, I just want to list all nodes associated to a taxonomy(category) term.
I've found a solution that's better suited to my needs, I'll explain it below. My solutions allows the client to use this procedure to add a product:
To make it a little more visual
So here's what you need:
Both solutions have their pros and cons. abiconsulting, for your multiple-PVT grouping needs, if you decide to use my solution (in the future) you can just show the nodes associated to multiple taxonomy terms using Views.
Thanks for the help! And by the way, "my solution" is mostly taken from Commerce Kickstart if anyone wants to see it in action.