0

Magento 2 I am programmatically adding text swatch options but label is not getting displayed. enter image description here

I have referred links where many such issues are mentioned faced by different people

Magento 2 : How to save swatch_text attribute options programatically?

Can someone guide me know how to solve this issue?

Following is the code I have used?

  $attributeDetails = $objectManager->create('MagentoEavModelConfig')->getAttribute("catalog_product", $attributeCode);
    //print_r($attributeDetails->getId()); exit();
    $attributeId = $attributeDetails->getId();
    $languageValues[0]=$label; 
    $languageValues[1]=$label;
    /* @var $attr MagentoEavModelEntityAttribute */
    $attr = $objectManager->create('MagentoEavModelEntityAttribute'); 
    $attr->load($attributeId); 
    $option = [];
    $option['value'][$languageValues[0]] = $languageValues;
    $attr->addData(array('option' => $option));
    $attr->save();

Your Answer

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

Browse other questions tagged or ask your own question.