/**
  * @param int|null $entityId
  * @param int|null $localeId
  * @param string|FallbackType $fieldValue
  * @return LocalizedFallbackValue
  */
 protected function generateLocalizedFallbackValue($entityId, $localeId, $fieldValue)
 {
     $localizedFallbackValue = null;
     if ($entityId) {
         $localizedFallbackValue = $this->findLocalizedFallbackValue($entityId);
     }
     if (!$localizedFallbackValue) {
         $localizedFallbackValue = new LocalizedFallbackValue();
     }
     $localizedFallbackValue->setLocale($localeId ? $this->findLocale($localeId) : null);
     if ($fieldValue instanceof FallbackType) {
         $localizedFallbackValue->setFallback($fieldValue->getType());
         $this->propertyAccessor->setValue($localizedFallbackValue, $this->field, null);
     } else {
         $localizedFallbackValue->setFallback(null);
         $this->propertyAccessor->setValue($localizedFallbackValue, $this->field, $fieldValue);
     }
     return $localizedFallbackValue;
 }
 /**
  * @param AttributeOption $masterOption
  * @param int $localeId
  * @param string|FallbackType $value
  * @param int $order
  * @return null|AttributeOption
  */
 protected function generateOption(AttributeOption $masterOption, $localeId, $value, $order)
 {
     if ($localeId) {
         $option = $masterOption->getRelatedOptionByLocaleId($localeId);
         if (!$option) {
             $option = new AttributeOption();
             $option->setLocale($this->databaseHelper->findLocale($localeId));
             $masterOption->addRelatedOption($option);
         }
     } else {
         $option = $masterOption;
     }
     if ($value instanceof FallbackType) {
         $option->setFallback($value->getType())->setValue(null);
     } else {
         $option->setFallback(null)->setValue($value);
     }
     $option->setOrder($order);
     return $option;
 }