Example #1
0
 /**
  * test importFromAmazonResult
  *
  * @param mixed $result
  * @param bool  $expectedResult
  *
  * @dataProvider dataImportFromAmazonResult
  */
 public function testImportFromAmazonResult($result, $expectedResult)
 {
     $this->assertEquals($expectedResult, $this->product->importFromAmazonResult($result));
     if ($expectedResult) {
         $this->assertNull($this->product->getModel());
         $this->assertEquals('title', $this->product->getTitle());
     }
 }
Example #2
0
 /**
  * Get a product matching a given id.
  *
  * @param string $marketplaceId
  * @param string $idType
  * @param string $id
  *
  * @return array
  */
 public function getMatchingProductForId($marketplaceId, $idType, $id)
 {
     try {
         $params = array('MarketplaceId' => $marketplaceId, 'IdType' => $idType, 'IdList.Id.1' => $id, 'SellerId' => $this->merchantId);
         /** @var \DOMDocument $result */
         $result = $this->mwsConnection->executeCommand('getMatchingProductForId', $params);
         $xpath = new \DOMXpath($result);
         $xpath->registerNamespace('mws', 'http://mws.amazonservices.com/schema/Products/2011-10-01');
         $productData = $xpath->query('//mws:Products/mws:Product')->item(0);
         if (!$productData) {
             return $this->generateErrorResponse('No product found');
         }
         $product = new Product();
         $product->importFromAmazonResult($productData);
         return $this->generateSuccessResponse(array('product' => $product));
     } catch (\Exception $e) {
         return $this->generateErrorResponse('Error during request');
     }
 }