/** * @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; }