public function getCompetitivePricingForId($ProductID) { WPLA()->logger->info('getCompetitivePricingForId() - ' . join(', ', $ProductID)); $this->initAPI('Products'); $request = new MarketplaceWebServiceProducts_Model_GetCompetitivePricingForASINRequest(); $request->setSellerId($this->SellerId); $request->setMarketplaceId($this->MarketplaceId); // set idList if (!is_array($ProductID)) { $ProductID = array($ProductID); } $idList = new MarketplaceWebServiceProducts_Model_ASINListType(); $idList->setASIN($ProductID); $request->setASINList($idList); // invoke request try { $response = $this->service->GetCompetitivePricingForASIN($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)); // echo "<pre>parsed_xml: ";print_r($parsed_xml);echo"</pre>"; // unify results for single and multiple items - result is an array of items // if ( is_array( $parsed_xml->products ) ) { // $products = $parsed_xml->products; // } else { // $products = array( $parsed_xml->products ); // } $result = new stdClass(); $result->products = $parsed_xml; $result->success = true; // log to db - parsed request $this->dblogger->updateLog(array('response' => $xml_data, 'result' => json_encode($result->products), '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(); // 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; }