I am trying to save some values in my attribute by programmatically. My attribute name is storage. type is dropdown I am trying to save values like 32GB or 16GB this values do not saved but if I used 'Black' or 'White' values ,it saved this kind of data

I am using Magento 2.3.4 Here is code

$optionValue = '32GB';
$attributeCode= 'storage';
                $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
                $entityType = 'catalog_product';
                $attributeInfo = $objectManager->get(\Magento\Eav\Model\Entity\Attribute::class)
                                     ->loadByCode($entityType, $attributeCode);
              $attributeFactory = $objectManager->get('\Magento\Catalog\Model\ResourceModel\Eav\Attribute');
                $storeManager = $objectManager->get('Magento\Store\Model\StoreManagerInterface');
              $attributeId = $attributeInfo->getAttributeId();
              $attribute_arr = [$optionValue];
              $option = array();
              $option['attribute_id'] = $attributeId;
              foreach($attribute_arr as $key=>$value){
                  foreach($storeManager as $store){
                      $option['value'][$value][$store->getId()] = $value;
              if ($option) {
                  $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
                $eavSetupFactory = $objectManager->create('\Magento\Eav\Setup\EavSetup');
            }catch(Exception $e){
              echo $e->getMessage();


Your Answer

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