I have a configurable product created and also simple products.

I want to add the option on the forme and poids attribute to link them. These options are properly configured, they appear in the admin if I want to add them from the admin


But I'm creating them through an import.

I have :

  • The instance of the configurable product
  • The instance of the simple product
  • The attribute value

This is what I have done which isn't working apparently

This is what I'm doing in case I'm currently reading a poids attribute

case 'poids':
    $attribute = $this->eavAttributeRepository->get(
    $usedAttributes = $configurable_product->getTypeInstance()->getUsedProductAttributeIds($configurable_product);
    $configurableAttributesData =

    $value = $attribute['value'];
    $configurableProductsData[$childProductId] = array(
        $k => array( //$k is an increment on the attribute i read 
            'label' => 'Poids', //attribute label
            'attribute_id' => $attribute->getAttributeId(),
            'value_index' => $this->poidsOptions->getLabelValue($value),
            'is_percent'    => 0,
            'pricing_value' => $childPrice,
    }catch(Exception $eI){

No error printed, but no options neither appearing in my configurable


Any ideas?


1 Answer 1


Each configurable product must have an attribut set This attribut set contain attributs

Create or modify the product attribut set

Stores >> Attritubes >> Attribut set

Drag and drop the attribut

From your configurable product select the attribut set, then link your simple product to the configurable

enter image description here

I hope I understood the request.

  • I can link them threw the admin already this isn't an issue; what is not working is when I try to do it programmaticaly
    – Claims
    Commented Dec 2, 2021 at 9:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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