public function getMatchingProductForId($ProductID, $IdType = 'ASIN') { WPLA()->logger->info('getMatchingProductForId() - ' . $ProductID); $this->initAPI('Products'); $request = new MarketplaceWebServiceProducts_Model_GetMatchingProductForIdRequest(); $request->setSellerId($this->SellerId); $request->setMarketplaceId($this->MarketplaceId); $request->setIdType($IdType); // set idList if (!is_array($ProductID)) { $ProductID = array($ProductID); } $idList = new MarketplaceWebServiceProducts_Model_IdListType(); $idList->setId($ProductID); $request->setIdList($idList); // invoke request try { $response = $this->service->GetMatchingProductForId($request); // parse XML response $dom = new DOMDocument(); $dom->loadXML($response->toXML()); $dom->preserveWhiteSpace = false; $dom->formatOutput = true; $xml_data = $dom->saveXML(); // WPLA()->logger->info('XML: '.print_r($xml_data,1)); $parsed_xml = $this->parseXML($xml_data); WPLA()->logger->debug('parsed_xml: ' . print_r($parsed_xml, 1)); // $res = $response->getGetMatchingProductForIdResult(); // echo("ResponseHeaderMetadata: " . $response->getResponseHeaderMetadata() . "\n"); $result = new stdClass(); $result->product = $parsed_xml; $result->success = true; // log to db - parsed request $this->dblogger->updateLog(array('response' => $xml_data, 'result' => json_encode($result->product), 'success' => 'Success')); return $result; } catch (MarketplaceWebServiceProducts_Exception $ex) { $error = new stdClass(); $error->ErrorMessage = $ex->getMessage(); $error->ErrorCode = $ex->getErrorCode(); $error->StatusCode = $ex->getStatusCode(); $error->ErrorType = $ex->getErrorType(); $error->RequestId = $ex->getRequestId(); $error->XML = $ex->getXML(); $error->HeaderMeta = $ex->getResponseHeaderMetadata(); $error->success = false; // log to db - parsed request $this->dblogger->updateLog(array('result' => json_encode($error), 'success' => 'Error')); return $error; } $result = new stdClass(); $result->success = false; return $result; }