/**
  * @return Product
  */
 protected function getFixtureBookB()
 {
     $config = $this->serviceManager->get('ApplicationConfig');
     $fixtures = $config['productTesting']['fixtures'];
     //lords of salem     $fixtures['B00KY20LL2']
     $product = new Product();
     $xml = simplexml_load_file($fixtures['B004UMNUE2']);
     $product->setByResponseObject($xml->Items->Item);
     return $product;
 }
 public function askApiAction()
 {
     $asin = $this->getRequest()->getParam('id');
     $countryCode = strtoupper($this->getRequest()->getParam('tld'));
     /** @var  $apaiIO  ApaiIOWrapper */
     $apaiIO = $this->synchronize->getApaiIOWrapper();
     $response = $apaiIO->getByASIN($asin, $countryCode);
     $product = new Product();
     $product->setByResponseObject($response->Items->Item);
     /** @var  $ps  ProductServiceInterface */
     $ps = $this->synchronize->getProductService();
     $ps->getEntityManager()->persist($product);
     $ps->getEntityManager()->flush();
 }
 /**
  * @param \SimpleXMLElement $xmlObject
  * @throws \Exception
  */
 public function createProductByXml(\SimpleXMLElement $itemDetails)
 {
     $product = new Product();
     $product->setByResponseObject($itemDetails);
     //check if we have it already in db
     $searchForProduct = $this->getProductByAsin($product->getAsin());
     if (null !== $searchForProduct) {
         return $searchForProduct;
     }
     $imageSmall = new Image($itemDetails->SmallImage->URL, Image::SIZE_SMALL, $itemDetails->SmallImage->Width, $itemDetails->SmallImage->Height);
     $imageMedium = new Image($itemDetails->MediumImage->URL, Image::SIZE_MEDIUM, $itemDetails->MediumImage->Width, $itemDetails->MediumImage->Height);
     $imageLarge = new Image($itemDetails->LargeImage->URL, Image::SIZE_LARGE, $itemDetails->LargeImage->Width, $itemDetails->LargeImage->Height);
     $product->setImages([$imageSmall, $imageMedium, $imageLarge]);
     //Price
     $listPrice = new Price();
     if ($itemDetails->ItemAttributes->ListPric !== null) {
         $listPrice->setByResponseObject($itemDetails->ItemAttributes->ListPrice);
         $product->setListPrice($listPrice);
     }
     //Offer
     if ($itemDetails->Offers->TotalOffers > 0) {
         $offer = new Offer();
         $priceOffer = new Price();
         $priceOffer->setByResponseObject($itemDetails->Offers->Offer->OfferListing->Price);
         $offer->setByResponseObject($itemDetails, $priceOffer);
         $product->setOffers(array($offer));
     }
     return $product;
 }