/** * {@inheritdoc} */ public function getIdentifier($rootIdentifier = 'attribute_id') { if ($this->isValid()) { return sha1(sprintf(Mapper::IDENTIFIER_FORMAT, $rootIdentifier, $this->clientParameters->getSoapUrl())); } else { return ''; } }
/** * Get mapper identifier * @param string $rootIdentifier * * @return string */ public function getIdentifier($rootIdentifier = 'generic') { if ($this->isValid()) { return sha1(sprintf(self::IDENTIFIER_FORMAT, $rootIdentifier, $this->clientParameters->getSoapUrl())); } else { return ''; } }
/** * Call soap api. * * @param string $resource * @param array $params * * @return array * * @throws NotConnectedException * @throws SoapCallException */ public function call($resource, $params = null) { if ($this->isConnected()) { try { $stopWatch = new Stopwatch(microtime(true)); $stopWatch->start('magentoSoapCall'); $response = $this->client->call($this->session, $resource, $params); $event = $stopWatch->stop('magentoSoapCall'); $this->profiler->logCallDuration($event, $resource); } catch (\SoapFault $e) { if ($resource === 'core_magento.info' && $e->getMessage() === AbstractGuesser::MAGENTO_CORE_ACCESS_DENIED) { $response = ['magento_version' => AbstractGuesser::UNKNOWN_VERSION]; } elseif ($e->getMessage() === AbstractGuesser::MAGENTO_CORE_ACCESS_DENIED) { throw new SoapCallException(sprintf('Error on Magento soap call to "%s" : "%s" Called resource : "%s" with parameters : %s.' . ' Soap user needs access on this resource. Please ' . 'check in your Magento webservice soap roles and ' . 'users configuration.', $this->clientParameters->getSoapUrl(), $e->getMessage(), $resource, json_encode($params)), $e->getCode(), $e); } else { throw new SoapCallException(sprintf('Error on Magento soap call to "%s" : "%s". Called resource : "%s" with parameters : %s', $this->clientParameters->getSoapUrl(), $e->getMessage(), $resource, json_encode($params)), $e->getCode(), $e); } } if (is_array($response) && isset($response['isFault']) && $response['isFault']) { throw new SoapCallException(sprintf('Error on Magento soap call to "%s" : "%s". Called resource : "%s" with parameters : %s.' . 'Response from API : %s', $this->clientParameters->getSoapUrl(), $e->getMessage(), $resource, json_encode($params), json_encode($response))); } return $response; } else { throw new NotConnectedException(); } }
/** * It connects to the url and give response. * * @param MagentoSoapClientParameters $clientParameters * * @return \Guzzle\Http\Message\Response * * @throws \Exception */ protected function connect($clientParameters) { $parametersHash = $clientParameters->getHash(); if (!isset($this->resultCache[$parametersHash])) { $guzzleParams = ['connect_timeout' => self::CONNECT_TIMEOUT, 'timeout' => self::TIMEOUT, 'auth' => [$clientParameters->getHttpLogin(), $clientParameters->getHttpPassword()]]; $request = $this->client->get($clientParameters->getSoapUrl(), [], $guzzleParams); $request->getCurlOptions()->set(CURLOPT_CONNECTTIMEOUT, self::CONNECT_TIMEOUT); $request->getCurlOptions()->set(CURLOPT_TIMEOUT, self::TIMEOUT); try { $response = $this->client->send($request); $this->resultCache[$parametersHash] = $response; } catch (\Exception $e) { $this->resultCache[$parametersHash] = $e; throw $e; } } else { $response = $this->resultCache[$parametersHash]; if ($response instanceof \Exception) { throw $response; } } return $response; }