Skip to content

Instantly share code, notes, and snippets.

@rhoerr
Last active December 2, 2025 19:20
Show Gist options
  • Select an option

  • Save rhoerr/a55285c9cabad6b87d592d5db7589262 to your computer and use it in GitHub Desktop.

Select an option

Save rhoerr/a55285c9cabad6b87d592d5db7589262 to your computer and use it in GitHub Desktop.
MySQL views to aggregate Magento 2 EAV data -- requires MySQL 5.7+ or equivalent

Important

This EAV debugger tool has been repackaged and released as a proper Magento module now.

Please install it using composer. https://github.com/mage-os-lab/module-eav-debug-views

Install with:

composer require --dev mage-os/module-eav-debug-views
bin/magento setup:upgrade
@rhoerr
Copy link
Author

rhoerr commented May 9, 2025

These queries/views aggregate all EAV values for each entity into a JSON column (eav_int, eav_text, etc) for easier debugging. For scoped entities, any scope values will be appended as "{attribute_code}:{store_id}"="{value}".

Don't use these for anything in runtime code. Be careful about how much data you select at once, if you have a large site.

I covered products, categories, customers, and addresses at this point. May put them into a composer-installable module if people would find it valuable.

You can use JSON functions on the EAV columns, for example:

SELECT *
FROM `dev_category`
WHERE JSON_EXTRACT(eav_int, "$.include_in_menu")=0;

Or:

SELECT
    entity_id,
    sku,
    JSON_EXTRACT(eav_varchar, "$.name") as name,
    JSON_EXTRACT(eav_decimal, "$.price") as price,
    eav_varchar
FROM `dev_product`
ORDER BY sku ASC
LIMIT 30

@rhoerr
Copy link
Author

rhoerr commented Dec 2, 2025

You can now find this as a Magento module at Mage-OS Lab: https://github.com/mage-os-lab/module-eav-debug-views

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment