Magento – SQL Query to fetch all child SKUs by using the configurable SKU

ce-1.9.2.0magento-1.9productskusql

I am trying to create a SQL query that will display all the SKUs of a simple product that are related to a configurable product. I will add the configurable SKU via a form field that I want to query.

Magento 1.9.2

Best Answer

$parentSku = 'testSku';

SELECT t2.sku FROM 
(SELECT b.child_id 
FROM `catalog_product_entity` a

LEFT JOIN `catalog_product_relation` b
ON b.`parent_id` = a.`entity_id`

WHERE a.sku = '{$parentSku}') t1

LEFT JOIN catalog_product_entity t2
ON t1.child_id = t2.`entity_id`
Related Topic