I am working on a custom shop module.

i have a custom entity content for my products and i want add some configuration for shipment.

For example :

my product has a weight and differents price for a weight.

So i have 3 way i think :

  • Custom table, but i am looking for a better way
  • Config Entity ?
  • Entity content ?

i use drupal console, but when i create a ConfigEntity type, i can't add custom field like weight / price. I can juste create a line with a machine name, i don't know how work this entity.

I need to add line like this :

First item Weight min : 100 Weight max : 500 Price : 10$

Second item Weight min : 500 Weight max : 1000 Price : 20$


What i should use for add config like this ?

Custom tables ? Config Entity ? Entity content ?

  • I am unclear what the actual question is. Is it "How do I add fields to a config entity?" or "Should I use a config entity or a custom table?" – mradcliffe Mar 28 '16 at 11:45
  • i know we can't add custom field to configEntity, the question is what i need to use for get config to my module – Kevin Mar 28 '16 at 11:49
  • It is possible to add fields to configuration entities. – mradcliffe Mar 28 '16 at 12:04
  • oh, i read it wasn't... ok so i ll look into this thank you – Kevin Mar 28 '16 at 12:07
  • Maybe I misunderstood. You should be able to add an arbitrary field in your configuration schema YAML. I think the key module schema does this. Also drupal.org/node/1905070 – mradcliffe Mar 28 '16 at 12:21

Your Answer

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

Browse other questions tagged or ask your own question.