i need to add text swatch attribute value through script. I'am able to add the attribute but swatch value is not adding. Below is the code i using -

    $attributeDetails = $objectManager->create('Magento\Eav\Model\Config')->getAttribute("catalog_product", $attributeCode);
    //print_r($attributeDetails->getId()); exit();
    $attributeId = $attributeDetails->getId();
    /* @var $attr \Magento\Eav\Model\Entity\Attribute */
    $attr = $objectManager->create('\Magento\Eav\Model\Entity\Attribute'); 
    $option = [];
    $option['value'][$languageValues[0]] = $languageValues;
    $attr->addData(array('option' => $option));

enter image description here

Here in image test is the value i am trying to create. Any idea how to do it? Any help would be appreciated. Thanks in advance.

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.