/**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     foreach ($this->attributes as $item) {
         // Create attribute label
         $label = new AttributeLabel();
         $label->setValue($item['label']);
         // Create attribute
         $attribute = new Attribute();
         $attribute->setCode($item['code']);
         $attribute->setType($item['type']);
         $attribute->setSharingType(SharingType::GENERAL);
         $attribute->setLocalized($item['localized']);
         $attribute->setSystem($item['system']);
         $attribute->setRequired($item['required']);
         $attribute->setUnique($item['unique']);
         $attribute->addLabel($label);
         if (isset($item['options'])) {
             foreach ($item['options'] as $optionItem) {
                 $masterOption = new AttributeOption();
                 $masterOption->setValue($optionItem['value']);
                 $masterOption->setOrder($optionItem['order']);
                 $attribute->addOption($masterOption);
             }
         }
         $manager->persist($attribute);
     }
     if (!empty($this->attributes)) {
         $manager->flush();
         $manager->clear();
     }
 }
 /**
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $attribute = new Attribute();
     $attribute->setCode(self::ATTRIBUTE_CODE)->setType(Select::NAME)->setSharingType(SharingType::GENERAL);
     foreach (self::$options as $localeCode => $options) {
         $locale = $localeCode ? $this->getLocaleByCode($manager, $localeCode) : null;
         foreach ($options as $order => $value) {
             $option = new AttributeOption();
             $option->setLocale($locale)->setValue($value)->setOrder($order);
             $attribute->addOption($option);
         }
     }
     $manager->persist($attribute);
     $manager->flush($attribute);
     $manager->clear();
 }
 /**
  * @param Attribute $attribute
  * @param array $options
  */
 public function setDefaultOptions(Attribute $attribute, array $options)
 {
     $attributeOptions = [];
     $attributeDefaultValues = [];
     foreach ($options as $optionData) {
         $order = $this->getOption($optionData, 'order', 0);
         $data = $this->getOption($optionData, 'data', []);
         $masterOptionId = $this->getOption($optionData, 'master_option_id');
         $masterOption = $attribute->getOptionById($masterOptionId);
         if (!$masterOption) {
             $masterOption = new AttributeOption();
             $attribute->addOption($masterOption);
         }
         foreach ($data as $localeId => $localeData) {
             $localeValue = $this->getOption($localeData, 'value', '');
             $option = $this->generateOption($masterOption, $localeId, $localeValue, $order);
             $attributeOptions[] = $option;
             if (!empty($localeData['is_default'])) {
                 $attributeDefaultValues[] = $this->generateOptionDefaultValue($attribute, $option, $localeId);
             }
         }
     }
     $this->propertyAccessor->setValue($attribute, 'options', $attributeOptions);
     $this->propertyAccessor->setValue($attribute, 'defaultValues', $attributeDefaultValues);
 }