AI Reports

Magento 2 SQL queries › Products and catalogue

Which products are enabled by default but disabled in a store view?

Short answer: A store-view value overrides the default. Find status values of Disabled (2) saved at store-view level while the default is Enabled (1).

In the Magento admin

  1. Open the product, switch the Scope switcher at the top to each store view, and look at Enable Product.

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.

Magento Open Source

SELECT e.sku, s.code AS store_view
FROM catalog_product_entity e
JOIN eav_entity_type t ON t.entity_type_code = 'catalog_product'
JOIN eav_attribute a_status ON a_status.entity_type_id = t.entity_type_id AND a_status.attribute_code = 'status'
JOIN catalog_product_entity_int def ON def.entity_id = e.entity_id AND def.attribute_id = a_status.attribute_id AND def.store_id = 0 AND def.value = 1
JOIN catalog_product_entity_int sv  ON sv.entity_id  = e.entity_id AND sv.attribute_id  = a_status.attribute_id AND sv.store_id  > 0 AND sv.value  = 2
JOIN store s ON s.store_id = sv.store_id
ORDER BY e.sku, s.code;

Adobe Commerce

Product, category, rule and CMS values are stored per version and joined on row_id (why):

SELECT e.sku, s.code AS store_view
FROM catalog_product_entity e
JOIN eav_entity_type t ON t.entity_type_code = 'catalog_product'
JOIN eav_attribute a_status ON a_status.entity_type_id = t.entity_type_id AND a_status.attribute_code = 'status'
JOIN catalog_product_entity_int def ON def.row_id = e.row_id AND def.attribute_id = a_status.attribute_id AND def.store_id = 0 AND def.value = 1
JOIN catalog_product_entity_int sv  ON sv.row_id  = e.row_id AND sv.attribute_id  = a_status.attribute_id AND sv.store_id  > 0 AND sv.value  = 2
JOIN store s ON s.store_id = sv.store_id
WHERE e.created_in <= UNIX_TIMESTAMP() AND e.updated_in > UNIX_TIMESTAMP()
ORDER BY e.sku, s.code;

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