Last active
August 29, 2015 14:08
-
-
Save groggu/ab42c04bc4b6b2b202b2 to your computer and use it in GitHub Desktop.
Magento - Get configurable product's total stock qty and is_in_stock status using one child's product ID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
count(product_id), | |
sum(cataloginventory_stock_item.qty) as child_qty, | |
sum(cataloginventory_stock_item.is_in_stock) > 0 as some_child_in_stock | |
FROM cataloginventory_stock_item | |
WHERE product_id in ( | |
SELECT | |
parent.product_id | |
FROM | |
catalog_product_super_link as parent | |
WHERE | |
parent.parent_id=( | |
SELECT | |
parent.parent_id | |
FROM | |
catalog_product_super_link as parent | |
WHERE | |
parent.product_id=1076131)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment