I can do this to get all attributes for a product:

$parentProduct = /* shirt (configurable) */;
$childProduct = /* shirt: blue, medium (simple) */;

$attributes = $childProduct->getAttributes();
foreach ( $attributes as $attribute ) {
    echo $attribute->getFrontend()->getLabel($childProduct) . ': ' . $attribute->getFrontend()->getValue($childProduct) . '<br />';

How can I limit this to just the attributes used to configure this product? (e.g. colour and size)


You can get the configurable attributes like this:

$attributes = $parentProduct->getTypeInstance()->getConfigurableAttributes($parentProduct());
  • It returns all attributes. Let's say I need "color" attribute and my configurable product has simple products with Black and White color. But simple product with color White are disabled. But this returns Black and White, but it should return only "Black"
    – FosAvance
    Feb 27 '17 at 14:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.