/** * @param int $idProductOptionValueUsage * @param string $localeCode * * @return \Generated\Shared\Transfer\ProductOptionTransfer */ public function getProductOption($idProductOptionValueUsage, $localeCode) { $localeTransfer = $this->localeFacade->getLocale($localeCode); $productOptionTransfer = new ProductOptionTransfer(); $productOptionTransfer->setIdOptionValueUsage($idProductOptionValueUsage)->setLocaleCode($localeCode); $result = $this->queryContainer->queryProductOptionValueUsageWithAssociatedAttributes($idProductOptionValueUsage, $localeTransfer->getIdLocale())->select([self::COL_PRICE, self::COL_TRANSLATION_TYPE, self::COL_TRANSLATION_VALUE])->findOne(); $productOptionTransfer->setLabelOptionType($result[self::COL_TRANSLATION_TYPE]); $productOptionTransfer->setLabelOptionValue($result[self::COL_TRANSLATION_VALUE]); $price = $result[self::COL_PRICE]; if ($price === null) { $productOptionTransfer->setUnitGrossPrice(0); } else { $productOptionTransfer->setUnitGrossPrice((int) $price); } return $productOptionTransfer; }
/** * @param \Orm\Zed\ProductOption\Persistence\SpyProductOptionValue $productOptionValueEntity * @param array $localizedNames * * @return void */ protected function createOrUpdateOptionValueTranslations(SpyProductOptionValue $productOptionValueEntity, array $localizedNames) { foreach ($localizedNames as $localeName => $localizedOptionValueName) { if ($this->localeFacade->hasLocale($localeName) === false) { continue; } $localeTransfer = $this->localeFacade->getLocale($localeName); $translationEntity = $this->queryContainer->queryProductOptionValueTranslationByFks($productOptionValueEntity->getIdProductOptionValue(), $localeTransfer->getIdLocale())->findOneOrCreate(); $translationEntity->setName($localizedOptionValueName); $translationEntity->setFkLocale($localeTransfer->getIdLocale()); $translationEntity->setFkProductOptionValue($productOptionValueEntity->getIdProductOptionValue()); $translationEntity->save(); $productOptionValueEntity->addSpyProductOptionValueTranslation($translationEntity); } }