Magento – Creating configurable product but size attribute not available to choose in Step 1 of creating configurations

attributesconfigurable-productmagento2

Hope you can help.

I've set up a size attribute in STORES > PRODUCT.

I've created a new attribute set in STORES > ATTRIBUTE SET and dragged the 'size' attribute into the middle column.

After doing this, I go to setup a new Configurable product.

  1. I select Add Configurable Product.
  2. Select the new attribute set from the drop down.
  3. Enter the basic product details and click on the Create Configurations button.

In Step 1, only the color attribute is available for selection and I can't get the size attribute to appear.

I've tried changing the details in the size attribute to the same settings as in the color attribute but still no luck. Also changed to Global and has a greyed out 'multiple select' drop down.

Any ideas as to where I may be going wrong?

Best Answer

There are several other questions related to this problem, and I have not seen this mentioned in any of them.

In addition to the requirements posted by others (attribute should be global, user_defined, visible, and have input type select - or another single selection type) , as of version 2.2.5 there is also requirement that in order to be available for use in configurations an attribute must either have no apply_to (Product Types) specified, or the apply_to must include all three of the following product types, simple,virtual,and configurable.

It is not clear to me if this is a bug or a feature. Here is the applicable code from the file vendor\magento\module-configurable-product\Model\ConfigurableAttributeHandler.php

public function isAttributeApplicable($attribute)
{
    $types = [
        \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE,
        \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL,
        \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE,
    ];
    return !$attribute->getApplyTo() || count(array_diff($types, $attribute->getApplyTo())) === 0;
}
Related Topic