0

For products I have created new attribute brix_level which is a text field.

Now I need products data using SQL.

I am good at quries, but the EAV structure is beyond my level :D

Can anyone explain the structure of EAV, and which tables do I need to use to get these data.

Product ID, SKU, Product Title, Brix Level
  • What research did you do? The internet is full of articles related to EAV and magento EAV – vitoriodachef Jun 28 at 5:32
2

This is a good article https://belvg.com/blog/eav-in-magento-2.html that covers much of what you need, this is a magento 1 tutorial https://blog.magestore.com/entity-attribute-value-in-magento/ but the db stuff is still relevant.

The EAV model and the Magento EAV model is extensivly documented over the internet.

EDIT.

  • eav_attribute_table - main attribute table (attribute_code, attribute_id etc)
  • catalog_eav_attribute - additional attribute table, specific to product attributes only (is_used_in_promo_rule, is_searchable etc.)

  • catalog_product_entity - main product table

  • catalog_product_[backend_type] - values stored for each attribute based on their type
  • backend_type can be one of int|decimal|varchar|text|datetime
  • attributes with backend_type static are saved in the main table

    Using plain custom sql makes sense in very little occasions. You have to account or product type(simple, configurable..etc) and attribute set (eav_attribute_set).

Magento offers the possibility of adding custom and extension attributes on he product. You can also add product attributes directly from admin using the GUI.

You should find yourself at SQL level only if you really know what you are doing and if the situation really asks for it (e.g. optimization).

To retrieve the data you can use either collections or repositories

  • Thanks mate. I know the internet is full of documentation about EAV, but I am still unclear to understand it's database structure :) If you can tell me related tables to get the data I need that would be great. – Muhammad Wasif Jun 28 at 5:42
  • @MuhammadWasif I edited the answer. – vitoriodachef Jun 28 at 7:25
  • Wow. thanks a lot :) – Muhammad Wasif Jun 28 at 8:32

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.