public function synchronize($wishlistId, $countryCode)
 {
     $this->amazonCrawler->setWishlistId($wishlistId);
     $this->amazonCrawler->setCountryCode($countryCode);
     $items = $this->amazonCrawler->crawlItems();
     $itemsToFetch = array();
     $products = array();
     foreach ($items as $item) {
         $product = $this->productService->getProductByAsin($item['asin']);
         if (null === $product) {
             $itemsToFetch[] = $item['asin'];
         } else {
             $products[] = $product;
         }
     }
     if (0 === count($items)) {
         echo 'no products found' . PHP_EOL;
         return;
     }
     $apaiIoResultSet = $this->apaiIOWrapper->getByASINS($itemsToFetch, $item['tld']);
     foreach ($apaiIoResultSet as $itemDetails) {
         $product = $this->productService->createProductByXml($itemDetails);
         $products[] = $product;
         $this->productService->getEntityManager()->persist($product);
     }
     $wishList = $this->wishlistService->findByWishlistID($wishlistId);
     if (null === $wishList) {
         $wishList = new Wishlist();
         $wishList->setName('IDK');
         $wishList->setWishlistOwnerName('IDK');
         $wishList->setAmazonId($wishlistId);
         $wishList->setTld($countryCode);
         //@todo owner & so on
     }
     $wishList->setProducts($products);
     $this->wishlistService->persistWishList($wishList);
     $this->wishlistService->getEntityManager()->flush();
 }
 /**
  * fetch wishlist and write CSV
  */
 public function execute()
 {
     $amazonCrawler = new AmazonCrawler($this->client, $this->logger);
     $amazonCrawler->setCountryCode($this->countryCode);
     $amazonCrawler->setWishlistId($this->wishlistId);
     $items = $amazonCrawler->crawlItems();
     $items = array_merge([['Name', 'Price', 'Url', 'Image']], $items);
     // Saving each item row to the file
     $fh = fopen($this->pathToSave, 'w');
     foreach ($items as $item) {
         fputcsv($fh, $item);
     }
     fclose($fh);
 }