0

I have a custom content entities in my Shop module.

I want 2 tables :

  • Orders
  • Order line

I create a custom content entity for orders, but I ask about the way to do the order line.

Do I need to create a second custom entity content and make a field reference orders table inside?

Or there is a way to declare subTable into the main entitie (orders for me)?

  • Make the items as fields and attach it to the order entity. – user21641 Oct 25 '15 at 11:53
2

First, forget about tables. Drupal 8 mostly takes care of that for entities.

Think about data structures instead: entities and fields.

What do you want?

  • Two separate entities, both possibly extensible with additional fields, maybe different bundles (e.g. product and shipping line items). Then make two entity types, with a reference field from line items to the order.

  • Simpler, non-extensible line items. Then you can design them as a custom field type and add that as a base field with unlimited cardinality. (In this case, they will be stored in a separate table, but you don't need to know about that for the most part).

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.