AI Reports

Magento 2 SQL queries › Store setup

List all websites and store views with their codes.

Short answer: Stores › All Stores shows the tree; the query gives one flat table with every ID and code.

In the Magento admin

  1. Go to Stores › Settings › All Stores.

With one query

These queries only read data. Run them on a copy of your database if you can, or ask your developer to. If your tables have a prefix (set in app/etc/env.php), add it to each table name.

Works on Magento Open Source and Adobe Commerce:

SELECT w.website_id, w.code AS website_code, w.name AS website,
       g.group_id, g.name AS store,
       s.store_id, s.code AS store_view_code, s.name AS store_view, s.is_active
FROM store s
JOIN store_group g ON g.group_id = s.group_id
JOIN store_website w ON w.website_id = s.website_id
WHERE s.store_id > 0
ORDER BY w.sort_order, w.website_id, g.group_id, s.sort_order, s.store_id;

Good to know

Related

Gaurav Harsh

Gaurav Harsh is a Magento developer who works on large Adobe Commerce stores and builds AI Reports, a Magento extension for asking your store's data questions in plain English. LinkedIn