AI Reports

Magento 2 troubleshooting › Catalogue

Why is a product missing on one website but fine on another?

Short answer: Products belong to websites through catalog_product_website. A product that isn't assigned to a website doesn't exist there, whatever its stock or status.

Check it step by step

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.

1. The websites one product is on

Works on Magento Open Source and Adobe Commerce:

SET @sku = 'ABC-123';  -- your SKU
SELECT w.website_id, w.code, w.name
FROM catalog_product_entity e
JOIN catalog_product_website pw ON pw.product_id = e.entity_id
JOIN store_website w ON w.website_id = pw.website_id
WHERE e.sku = @sku;

2. Enabled, visible products missing from a website

Magento Open Source

SET @website = 'base';  -- the website code
SELECT e.sku
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 eav_attribute a_visibility ON a_visibility.entity_type_id = t.entity_type_id AND a_visibility.attribute_code = 'visibility'
JOIN catalog_product_entity_int st  ON st.entity_id  = e.entity_id AND st.attribute_id  = a_status.attribute_id     AND st.store_id  = 0 AND st.value = 1
JOIN catalog_product_entity_int vis ON vis.entity_id = e.entity_id AND vis.attribute_id = a_visibility.attribute_id AND vis.store_id = 0 AND vis.value IN (2, 3, 4)
WHERE NOT EXISTS (
  SELECT 1 FROM catalog_product_website pw
  JOIN store_website w ON w.website_id = pw.website_id
  WHERE pw.product_id = e.entity_id AND w.code = @website
)
ORDER BY e.sku;

Adobe Commerce

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

SET @website = 'base';  -- the website code
SELECT e.sku
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 eav_attribute a_visibility ON a_visibility.entity_type_id = t.entity_type_id AND a_visibility.attribute_code = 'visibility'
JOIN catalog_product_entity_int st  ON st.row_id  = e.row_id AND st.attribute_id  = a_status.attribute_id     AND st.store_id  = 0 AND st.value = 1
JOIN catalog_product_entity_int vis ON vis.row_id = e.row_id AND vis.attribute_id = a_visibility.attribute_id AND vis.store_id = 0 AND vis.value IN (2, 3, 4)
WHERE e.created_in <= UNIX_TIMESTAMP() AND e.updated_in > UNIX_TIMESTAMP()
  AND NOT EXISTS (
  SELECT 1 FROM catalog_product_website pw
  JOIN store_website w ON w.website_id = pw.website_id
  WHERE pw.product_id = e.entity_id AND w.code = @website
)
ORDER BY e.sku;

Website codes are in Stores › All Stores (or the store_website table).

How to fix it

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