Example #1
0
 /**
  * @return \Generated\Shared\Transfer\WishlistTransfer
  */
 public function getWishlist()
 {
     $wishlist = $this->wishlistQueryContainer->queryWishlist()->findOneByFkCustomer($this->customerTransfer->getIdCustomer());
     $wishlistTransfer = new WishlistTransfer();
     foreach ($wishlist->getSpyWishlistItems() as $wishlistItemEntity) {
         $wishlistItemTransfer = new ItemTransfer();
         $productEntity = $wishlistItemEntity->getSpyProduct();
         $wishlistItemTransfer->setGroupKey($wishlistItemEntity->getGroupKey())->setAddedAt($wishlistItemEntity->getAddedAt())->setIdProductAbstract($wishlistItemEntity->getFkProductAbstract())->setSku($productEntity->getSku())->setQuantity($wishlistItemEntity->getQuantity());
         $wishlistTransfer->addItem($wishlistItemTransfer);
     }
     return $wishlistTransfer;
 }
Example #2
0
 /**
  * @param \Generated\Shared\Transfer\WishlistTransfer $wishlist
  *
  * @return void
  */
 public function expandProductDetails(WishlistTransfer $wishlist)
 {
     foreach ($wishlist->getItems() as $item) {
         $productData = $this->productClient->getProductAbstractFromStorageByIdForCurrentLocale($item->getIdProductAbstract());
         foreach ($productData['product_concrete_collection'] as $product) {
             if ($product['sku'] !== $item->getSku()) {
                 continue;
             }
             $productConcrete = new ProductConcreteTransfer();
             $productConcrete->setName($product['name']);
             $productConcrete->setSku($product['sku']);
             $productConcrete->setAttributes($product['attributes']);
             $item->setProductConcrete($productConcrete);
         }
     }
 }
Example #3
0
 /**
  * @return array
  */
 protected function createIndex()
 {
     $wishlistItem = $this->wishlistTransfer->getItems();
     $wishlistIndex = [];
     foreach ($wishlistItem as $key => $cartItem) {
         if ($cartItem->getGroupKey()) {
             $wishlistIndex[$cartItem->getGroupKey()] = $key;
         }
     }
     return $wishlistIndex;
 }
Example #4
0
 /**
  * @return void
  */
 public function testIncreaseItem()
 {
     $productFacadeMock = $this->createProductFacadeProductConcreteMock();
     $wishlistTransfer = new WishlistTransfer();
     $wishlistItem = new ItemTransfer();
     $wishlistItem->setGroupKey(123);
     $wishlistItem->setQuantity(1);
     $wishlistTransfer->addItem($wishlistItem);
     $inMemory = new InMemory($wishlistTransfer, $productFacadeMock);
     $wishlistChangeTransfer = new WishlistChangeTransfer();
     $wishlistItem = new ItemTransfer();
     $wishlistItem->setGroupKey(123);
     $wishlistItem->setQuantity(1);
     $wishlistChangeTransfer->addItem($wishlistItem);
     $wishlist = $inMemory->increaseItems($wishlistChangeTransfer);
     $wishlistItem = $wishlist->getItems()[0];
     $this->assertEquals(2, $wishlistItem->getQuantity());
 }