To identify the attributes linking a configurable product (e.g., product ID 123
) to its child products, follow these steps:
Query the catalog_product_super_attribute table to get the attribute_id values linked to the configurable product.
SELECT cpsa.attribute_id
FROM catalog_product_super_attribute cpsa
WHERE cpsa.product_id = 123;
Use the attribute_id values obtained in the previous step to find their corresponding attribute_code from the eav_attribute table.
SELECT ea.attribute_id, ea.attribute_code, ea.frontend_label
FROM eav_attribute ea
WHERE ea.attribute_id IN (
SELECT cpsa.attribute_id
FROM catalog_product_super_attribute cpsa
WHERE cpsa.product_id = 123
);
This will give you the attribute codes and possibly the frontend labels for the attributes used by the configurable product.
If custom labels are defined for these attributes, fetch them from catalog_product_super_attribute_label.
SELECT cpsal.product_super_attribute_id, cpsal.use_default, cpsal.value
FROM catalog_product_super_attribute_label cpsal
WHERE cpsal.product_super_attribute_id IN (
SELECT cpsa.product_super_attribute_id
FROM catalog_product_super_attribute cpsa
WHERE cpsa.product_id = 123
);