Magento 2 SQL queries › Stock
Which products allow backorders?
Short answer: Backorders are set store-wide in configuration and can be overridden per product. The query lists the product-level overrides.
In the Magento admin
- Check the default in Stores › Configuration › Catalog › Inventory › Product Stock Options › Backorders.
- Per product: Advanced Inventory on the product page.
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, si.backorders, si.use_config_backorders, si.qty
FROM cataloginventory_stock_item si
JOIN catalog_product_entity e ON e.entity_id = si.product_id
WHERE si.use_config_backorders = 0
AND si.backorders > 0
ORDER BY e.sku;
Adobe Commerce
Product, category, rule and CMS values are stored per version and joined on row_id (why):
SELECT e.sku, si.backorders, si.use_config_backorders, si.qty
FROM cataloginventory_stock_item si
JOIN catalog_product_entity e ON e.entity_id = si.product_id
WHERE si.use_config_backorders = 0
AND si.backorders > 0
AND e.created_in <= UNIX_TIMESTAMP() AND e.updated_in > UNIX_TIMESTAMP()
ORDER BY e.sku;
The store-wide default (0 = no backorders, 1 = allow, 2 = allow and notify):
SELECT scope, scope_id, value
FROM core_config_data
WHERE path = 'cataloginventory/item_options/backorders';
Good to know
- If the default allows backorders, every product with
use_config_backorders = 1allows them too.