Ejemplo n.º 1
0
 /**
  * @return void
  */
 public function testImportProductOptionPresetConfiguration()
 {
     $product = $this->createProductConcrete();
     $optionShade = $this->createOptionTypeWithValue('SHADE', 'VIOLET');
     $optionFitting = $this->createOptionTypeWithValue('FITTING', 'CLASSIC');
     $productOptionShade = $this->createProductOptionTypeUsage($product, $optionShade);
     $productOptionValueUsageViolet = (new SpyProductOptionValueUsage())->setSpyProductOptionValue($optionShade->getSpyProductOptionValues()[0]);
     $productOptionShade->addSpyProductOptionValueUsage($productOptionValueUsageViolet);
     $productOptionShade->save();
     $productOptionFitting = $this->createProductOptionTypeUsage($product, $optionFitting);
     $productOptionValueUsageSmall = (new SpyProductOptionValueUsage())->setSpyProductOptionValue($optionFitting->getSpyProductOptionValues()[0]);
     $productOptionFitting->addSpyProductOptionValueUsage($productOptionValueUsageSmall);
     $productOptionFitting->save();
     $this->facade->importPresetConfiguration($product->getSku(), ['VIOLET', 'CLASSIC']);
     $this->facade->flushBuffer();
     $result = SpyProductOptionConfigurationPresetQuery::create()->findByFkProduct($product->getIdProduct());
     $this->assertEquals(1, $result->count());
     $values = $result[0]->getSpyProductOptionConfigurationPresetValues();
     foreach ($values as $value) {
         $this->assertContains($value->getFkProductOptionValueUsage(), [$productOptionValueUsageSmall->getIdProductOptionValueUsage(), $productOptionValueUsageViolet->getIdProductOptionValueUsage()]);
     }
     $this->performAssertionOnTouchTable($product->getFkProductAbstract());
 }
 /**
  * @return void
  */
 protected function buildProductOptionFacade()
 {
     $container = new Container();
     $container[self::FACADE_PRODUCT] = function (Container $container) {
         return $this->productFacade;
     };
     $container[self::FACADE_LOCALE] = function (Container $container) {
         return $this->localeFacade;
     };
     $container[self::QUERY_CONTAINER_PRODUCT] = function (Container $container) {
         return $this->productQueryContainer;
     };
     $container[self::PROPEL_CONNECTION] = function () {
         return (new Connection())->get();
     };
     $persistenceFactory = new ProductOptionPersistenceFactory();
     $persistenceFactory->setContainer($container);
     $this->productOptionQueryContainer->setFactory($persistenceFactory);
     $businessFactory = new ProductOptionBusinessFactory();
     $businessFactory->setContainer($container);
     $businessFactory->setQueryContainer($this->productOptionQueryContainer);
     $this->facade->setFactory($businessFactory);
 }
 /**
  * @param int $idProductOptionValueUsage
  * @param int $idLocale
  *
  * @return \Generated\Shared\Transfer\ProductOptionTransfer
  */
 public function getProductOption($idProductOptionValueUsage, $idLocale)
 {
     return $this->productOptionFacade->getProductOption($idProductOptionValueUsage, $idLocale);
 }
 /**
  * @param int $idTypeUsage
  *
  * @return string|null
  */
 public function getEffectiveTaxRateForTypeUsage($idTypeUsage)
 {
     return $this->productOptionFacade->getEffectiveTaxRateForTypeUsage($idTypeUsage);
 }