0

I am building a commerce marketplace, and have several field that I am reusing on multiple product types. It's getting tedious adding them over and over, so I'd like to include them in a field collection.

The issue is that fields within a field collection cannot be marked as (and I'm paraphrasing) "should be used as a product attribute." I'm assuming this is because the fields do not know that they will be used on a commerce product, so the option isn't available.

Does anybody know of a way to implement this functionality? I'm open to coding, I just don't know what I'd work on.

0

By default Drupal Commerce supports list type fields (list, term reference - list, etc.) as Product attributes, not sure but may be because pre-defined list of values.

It would be difficult to get the field collection as your product attribute, because attributes make the product Unique and using the field collection won't give you much feasibility to use every field value to differentiate between product. Instead you can re-use fields in every product type and get it working easily.

If you still would like to give field collection module a try, you can check Drupal Commerce module in detail for attributes implementation or refer Commerce Attributes Date module which allows date field to be used as Product Attributes (Drupal Commerce doesn't support Date type field as attribute by default).

2
  • The fields that I was trying to include were Lists/Term References, so they worked as attributes on their own. That's why I was hoping they would work inside the field collection field. I didn't solve this question, but I did find Field Tools (drupal.org/project/field_tools) which let's you clone a field from one bundle into any other bundle, which essentially solves my issue of adding/maintaining many instances of each field.
    – Mrweiner
    Mar 1 '16 at 6:06
  • Great. So you just need to export and import.
    – Yogesh
    Mar 1 '16 at 6:13
0

I wasn't able to answer the questions above, but I was able to solve my problem using Field Tools, which let's you clone fields to and from any bundles, as well as apply mass edits to all instances of a single field.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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