Skip to content

Instantly share code, notes, and snippets.

@groggu
Created October 24, 2014 14:56
Show Gist options
  • Save groggu/2ff2b3e0a6532b3b6e4f to your computer and use it in GitHub Desktop.
Save groggu/2ff2b3e0a6532b3b6e4f to your computer and use it in GitHub Desktop.
Magento - Validate stock against index values for all simple products
SELECT DISTINCT
catalog_product_entity.entity_id,
catalog_product_entity.sku,
catalog_product_entity.type_id,
cataloginventory_stock_item.qty AS `stock qty`,
cataloginventory_stock_item.is_in_stock,
cataloginventory_stock_status_idx.qty AS `idx qty`,
cataloginventory_stock_status_idx.stock_status
FROM cataloginventory_stock_item INNER JOIN cataloginventory_stock_status_idx ON cataloginventory_stock_item.product_id = cataloginventory_stock_status_idx.product_id
INNER JOIN catalog_product_entity ON catalog_product_entity.entity_id = cataloginventory_stock_item.product_id
WHERE cataloginventory_stock_item.qty <> cataloginventory_stock_status_idx.qty
and catalog_product_entity.type_id="simple"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment