2

I'm trying to create a content type that matches a product. The product can be made of several thing in different percentages:

Eg.

material 1:
    material 1.1: 5%
    material 1.2: 0%
    material 1.3: 20%
material 2: 75%
material 3: 0%
material 4:
    material 4.1 0%
    material 4.2 0%

I've built the materials hierarchy using taxonomies. How can I add a parameter to a taxonomy so I can do this?

I've tried using Field Collection, but the problem I encountered was the inability to work with Solr

1
  • make material 1 the vocabulary and then material 1.1, 1.2, 1.3 its terms.
    – No Sssweat
    Jan 25, 2016 at 7:30

2 Answers 2

3

You can use the Multifield module, it is a "lightweight" version of field collection, instead of creating an entity structure with relationships, it covers the simple use cases without creating the entity. It works with Solr.

I think that you must read this: Field Collection vs Entity Reference

4
  • Does it work with solr? I posted before this was edited into the question, but now when it is, it would be worth to mention it.
    – Mołot
    Jan 25, 2016 at 7:22
  • @Mołot yes it works with solr Jan 25, 2016 at 13:06
  • Guys, thank you for your fast answers, I'm gonna mark this as best answer, even though both answers we're very good. Multifield works fine. Another solution proposed by my team leader was adding a term refference for the taxonomy, and a field collection for taxonomy + percentage (hiding the normal term refference, and populating it at node_save hook). Jan 26, 2016 at 19:26
  • @TacheRazvan Happy ending ;-) god luck with your project Jan 26, 2016 at 19:32
3

There are two options:

  1. Create own module based on taxonomy. Most flexible, but also most complicated. That's what I would do, if I had time and motivation to play.

  2. Use Field collection - create a collection of term and percentage fields, and make this collection (not individual fields in it) multivalue. Warning: I know of no easy way to make sure your percentages adds up to 100%. I know how to do it easily in custom module.... see point 1.

3
  • Thank you for your prompt answer. The problem I've encountered with field collection, is that the solr module, does not work with Field collection. Jan 24, 2016 at 11:30
  • @TacheRazvan That's why you are generally supposed to tell what you have already tried and why it didn't work for you - if you tried anything, that is.
    – Mołot
    Jan 24, 2016 at 11:31
  • I'm sorry, I'm new to this, gonna edit the question. Jan 24, 2016 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.