コード例 #1
0
 /**
  * @return void
  */
 public function testPluginExpandsCartItemWithExpectedProductData()
 {
     $localeName = Store::getInstance()->getCurrentLocale();
     $localeTransfer = $this->localeFacade->getLocale($localeName);
     $taxRateEntity = new SpyTaxRate();
     $taxRateEntity->setRate(self::TAX_RATE_PERCENTAGE)->setName(self::TAX_RATE_NAME);
     $taxSetEntity = new SpyTaxSet();
     $taxSetEntity->addSpyTaxRate($taxRateEntity)->setName(self::TAX_SET_NAME);
     $productAbstractEntity = new SpyProductAbstract();
     $productAbstractEntity->setSpyTaxSet($taxSetEntity)->setAttributes('')->setSku(self::SKU_PRODUCT_ABSTRACT);
     $localizedAttributesEntity = new SpyProductLocalizedAttributes();
     $localizedAttributesEntity->setName(self::PRODUCT_CONCRETE_NAME)->setAttributes('')->setFkLocale($localeTransfer->getIdLocale());
     $productConcreteEntity = new SpyProduct();
     $productConcreteEntity->setSpyProductAbstract($productAbstractEntity)->setAttributes('')->addSpyProductLocalizedAttributes($localizedAttributesEntity)->setSku(self::SKU_PRODUCT_CONCRETE)->save();
     $changeTransfer = new CartChangeTransfer();
     $itemTransfer = new ItemTransfer();
     $itemTransfer->setSku(self::SKU_PRODUCT_CONCRETE);
     $changeTransfer->addItem($itemTransfer);
     $this->productCartConnectorFacade->expandItems($changeTransfer);
     $expandedItemTransfer = $changeTransfer->getItems()[0];
     $this->assertEquals(self::SKU_PRODUCT_ABSTRACT, $expandedItemTransfer->getAbstractSku());
     $this->assertEquals(self::SKU_PRODUCT_CONCRETE, $expandedItemTransfer->getSku());
     $this->assertEquals($productAbstractEntity->getIdProductAbstract(), $expandedItemTransfer->getIdProductAbstract());
     $this->assertEquals($productConcreteEntity->getIdProduct(), $expandedItemTransfer->getId());
 }
コード例 #2
0
ファイル: ProductManager.php プロジェクト: spryker/Product
 /**
  * @param \Generated\Shared\Transfer\ProductConcreteTransfer $productConcreteTransfer
  *
  * @return void
  */
 protected function createProductConcreteAttributes(ProductConcreteTransfer $productConcreteTransfer)
 {
     $idProductConcrete = $productConcreteTransfer->getIdProductConcrete();
     foreach ($productConcreteTransfer->getLocalizedAttributes() as $localizedAttributes) {
         $locale = $localizedAttributes->getLocale();
         $this->checkProductConcreteAttributesDoNotExist($idProductConcrete, $locale);
         $encodedAttributes = $this->encodeAttributes($localizedAttributes->getAttributes());
         $productAttributeEntity = new SpyProductLocalizedAttributes();
         $productAttributeEntity->setFkProduct($idProductConcrete)->setFkLocale($locale->getIdLocale())->setName($localizedAttributes->getName())->setAttributes($encodedAttributes);
         $productAttributeEntity->save();
     }
 }
コード例 #3
0
ファイル: ProductFacadeTest.php プロジェクト: spryker/Product
 /**
  * @group Product
  *
  * @return void
  */
 public function testGetProductConcrete()
 {
     $localeName = Store::getInstance()->getCurrentLocale();
     $localeTransfer = $this->localeFacade->getLocale($localeName);
     $taxRateEntity = new SpyTaxRate();
     $taxRateEntity->setRate(self::TAX_RATE_PERCENTAGE)->setName(self::TAX_RATE_NAME);
     $taxSetEntity = new SpyTaxSet();
     $taxSetEntity->addSpyTaxRate($taxRateEntity)->setName(self::TAX_SET_NAME);
     $productAbstractEntity = new SpyProductAbstract();
     $productAbstractEntity->setSpyTaxSet($taxSetEntity)->setAttributes('')->setSku(self::SKU_PRODUCT_ABSTRACT);
     $localizedAttributesEntity = new SpyProductLocalizedAttributes();
     $localizedAttributesEntity->setName(self::PRODUCT_CONCRETE_NAME)->setAttributes('')->setFkLocale($localeTransfer->getIdLocale());
     $productConcreteEntity = new SpyProduct();
     $productConcreteEntity->setSpyProductAbstract($productAbstractEntity)->setAttributes('')->addSpyProductLocalizedAttributes($localizedAttributesEntity)->setSku(self::SKU_PRODUCT_CONCRETE)->save();
     $productConcreteTransfer = $this->productFacade->getProductConcrete($productConcreteEntity->getSku());
     $this->assertEquals(self::PRODUCT_CONCRETE_NAME, $productConcreteTransfer->getName());
     $this->assertEquals(self::SKU_PRODUCT_CONCRETE, $productConcreteTransfer->getSku());
     $this->assertEquals(self::SKU_PRODUCT_ABSTRACT, $productConcreteTransfer->getProductAbstractSku());
     $this->assertEquals($productConcreteEntity->getIdProduct(), $productConcreteTransfer->getIdProductConcrete());
     $this->assertEquals($productAbstractEntity->getIdProductAbstract(), $productConcreteTransfer->getIdProductAbstract());
 }