/**
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->ids = DbFixturesLoader::loadFixtures();
     $this->facade = new ProductOptionFacade();
     $this->facade->setFactory(new ProductOptionBusinessFactory());
     $this->localeFacade = new LocaleFacade();
     $this->localeFacade->setFactory(new LocaleBusinessFactory());
     $this->productFacade = new ProductFacade();
     $this->productFacade->setFactory(new ProductBusinessFactory());
     $this->productQueryContainer = new ProductQueryContainer();
     $this->productOptionQueryContainer = new ProductOptionQueryContainer();
     $this->buildProductOptionFacade();
 }
 /**
  * @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);
     }
 }