/** * @param Attribute $attribute * @param array $labels */ public function setLabels(Attribute $attribute, array $labels) { foreach ($labels as $localeId => $label) { $attributeLabel = $attribute->getLabelByLocaleId($localeId); if (!$attributeLabel) { $attributeLabel = new AttributeLabel(); if ($localeId) { $attributeLabel->setLocale($this->databaseHelper->findLocale($localeId)); } $attribute->addLabel($attributeLabel); } if ($label instanceof FallbackType) { $attributeLabel->setValue(null)->setFallback($label->getType()); } else { $attributeLabel->setValue($label)->setFallback(null); } } }
/** * @param Attribute $attribute * @param AttributeOption $option * @param int $localeId * @return AttributeDefaultValue */ protected function generateOptionDefaultValue(Attribute $attribute, AttributeOption $option, $localeId) { $defaultValue = null; if ($option->getId()) { $defaultValue = $attribute->getDefaultValueByLocaleIdAndOptionId($localeId, $option->getId()); } if (!$defaultValue) { $defaultValue = new AttributeDefaultValue(); if ($localeId) { $defaultValue->setLocale($this->databaseHelper->findLocale($localeId)); } } $defaultValue->setOption($option); return $defaultValue; }