0

Magento 2.2 -- I am trying to build a module that would allow for custom attributes to be created in the admin panel. At this point, I'm stuck on what tables need to be created to allow for that functionality. Do I need to create one table that links to another? That's what I've seen elsewhere in the core code...

Thanks!

0

Magento has different entities: product, customer, category etc. https://magento.stackexchange.com/a/116504/43911

You don't need to create new tables for these entities to store values of attributes. Attributes can create from admin panel for a product or programmatically with installer Magento 2 : Add Product Attribute Programmatically

Also if you need to store any other values that don't relate to existing entities or configuration of a module ( Magento 2 : Add Product Attribute Programmatically ) then you need to have a separate new table https://devdocs.magento.com/videos/fundamentals/add-a-new-table-to-database/

  • Thanks! That helped clarify my thoughts. However, I'm not looking to just save attribute values, but actually create attributes in the admin panel (sorry if I misunderstood something in your answer...). For example, I want to have a page in the admin panel that allows custom attributes to be created for a customers order. Where would those custom attributes be saved? Would I have to create a new table for that? – IsaacP Jan 3 at 22:25
  • You need to create programmatically order attribute magento.stackexchange.com/a/131969/43911 – Anton Jan 3 at 23:13
  • But how would creating a new column in that table help when saving a new, custom attribute in the admin panel? I guess I'm not understanding how the custom attributes, created in the admin panel would get saved by doing that... – IsaacP Jan 3 at 23:31
  • You can use this one example and update/save a value of attribute in the Observer yereone.com/magento-2-how-to-add-new-order-attribute – Anton Jan 4 at 15:59

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.