/**
  * @group ProductCategory
  *
  * @return void
  */
 public function testCreateAttributeTypeCreatesAndReturnsId()
 {
     $abstractSku = 'AnAbstractTestProduct';
     $concreteSku = 'ATestProduct';
     $categoryName = 'ATestCategory';
     $localeName = 'ABCDE';
     $abstractName = 'abstractName';
     $categoryKey = '100TEST';
     $locale = $this->localeFacade->createLocale($localeName);
     $productAbstractTransfer = new ProductAbstractTransfer();
     $productAbstractTransfer->setSku($abstractSku);
     $productAbstractTransfer->setAttributes([]);
     $localizedAttributes = new LocalizedAttributesTransfer();
     $localizedAttributes->setAttributes([]);
     $localizedAttributes->setLocale($locale);
     $localizedAttributes->setName($abstractName);
     $productAbstractTransfer->addLocalizedAttributes($localizedAttributes);
     $idProductAbstract = $this->productFacade->createProductAbstract($productAbstractTransfer);
     $productConcreteTransfer = new ProductConcreteTransfer();
     $productConcreteTransfer->setSku($concreteSku);
     $productConcreteTransfer->setAttributes([]);
     $productConcreteTransfer->addLocalizedAttributes($localizedAttributes);
     $productConcreteTransfer->setIsActive(true);
     $this->productFacade->createProductConcrete($productConcreteTransfer, $idProductAbstract);
     $categoryTransfer = new CategoryTransfer();
     $categoryTransfer->setName($categoryName);
     $categoryTransfer->setCategoryKey($categoryKey);
     $idCategory = $this->categoryFacade->createCategory($categoryTransfer, $locale);
     $categoryNodeTransfer = new NodeTransfer();
     $categoryNodeTransfer->setFkCategory($idCategory);
     $categoryNodeTransfer->setIsRoot(true);
     $this->categoryFacade->createCategoryNode($categoryNodeTransfer, $locale, false);
     $this->productCategoryFacade->createProductCategoryMapping($abstractSku, $categoryName, $locale);
     $this->assertTrue($this->productCategoryFacade->hasProductCategoryMapping($abstractSku, $categoryName, $locale));
 }
예제 #2
0
 /**
  * @param \Generated\Shared\Transfer\ProductAbstractTransfer $product
  *
  * @return bool
  */
 public function writeProductAbstract(ProductAbstractTransfer $product)
 {
     $this->productStatement->execute([':sku' => $product->getSku(), ':attributes' => json_encode($product->getAttributes())]);
     foreach ($product->getLocalizedAttributes() as $localizedAttributes) {
         $this->attributesStatement->execute([':attributes' => json_encode($localizedAttributes->getAttributes()), ':name' => $localizedAttributes->getName(), ':productAbstractSku' => $product->getSku(), ':fkLocale' => $this->localeTransfer->getIdLocale()]);
     }
     return true;
 }
예제 #3
0
 /**
  * @param \Generated\Shared\Transfer\ProductAbstractTransfer $productAbstractTransfer
  *
  * @return void
  */
 protected function createProductAbstractImages(ProductAbstractTransfer $productAbstractTransfer)
 {
     $idProductAbstract = $productAbstractTransfer->getIdProductAbstract();
     foreach ($productAbstractTransfer->getProductImagesSets() as $productImagesSet) {
         $this->saveProductImageSet($idProductAbstract, $productImagesSet);
     }
 }
예제 #4
0
 /**
  * @group Product
  *
  * @return void
  */
 public function testGetAbstractSkuFromProductConcrete()
 {
     $this->assertFalse($this->productFacade->hasProductConcrete(self::SKU_PRODUCT_CONCRETE));
     $productAbstract = new ProductAbstractTransfer();
     $productAbstract->setSku(self::SKU_PRODUCT_ABSTRACT);
     $productAbstract->setAttributes([]);
     $productAbstract->addLocalizedAttributes($this->createLocalizedAttributesTransfer());
     $idProductAbstract = $this->productFacade->createProductAbstract($productAbstract);
     $productConcrete = new ProductConcreteTransfer();
     $productConcrete->setSku(self::SKU_PRODUCT_CONCRETE);
     $productConcrete->setAttributes([]);
     $productConcrete->addLocalizedAttributes($this->createLocalizedAttributesTransfer());
     $productConcrete->setIsActive(true);
     $this->productFacade->createProductConcrete($productConcrete, $idProductAbstract);
     $this->assertTrue($this->productFacade->hasProductConcrete(self::SKU_PRODUCT_CONCRETE));
     $this->assertEquals($this->productFacade->getAbstractSkuFromProductConcrete(self::SKU_PRODUCT_CONCRETE), self::SKU_PRODUCT_ABSTRACT);
 }
 /**
  * @param \Generated\Shared\Transfer\ProductAbstractTransfer $productAbstractTransfer
  *
  * @return \Orm\Zed\ProductCategory\Persistence\SpyProductCategory[]
  */
 public function getCategoriesByProductAbstract(ProductAbstractTransfer $productAbstractTransfer)
 {
     return $this->productCategoryQueryContainer->queryLocalizedProductCategoryMappingByIdProduct($productAbstractTransfer->getIdProductAbstract())->find();
 }