Guest User

Untitled

a guest
Mar 20th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.24 KB | None | 0 0
  1. [oauth_consumer_key] => x...0
  2. [oauth_consumer_secret] => j...l
  3. [store_base_url] => http://magento.example.com/
  4. [oauth_consumer_secret] => 5...n
  5.  
  6. /oauth/token/request
  7.  
  8. /oauth/token/access
  9.  
  10. $credentials = new OAuthCommonConsumerCredentials($consumerKey, $consumerSecret, $magentoBaseUrl);
  11. $oAuthClient = new OauthClient($credentials);
  12.  
  13. // get admin Token to create the customer Account in realm Data stores
  14. $ch = curl_init('http://openam/json/authenticate');
  15. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  16. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  17. curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  18. 'X-OpenAM-Username: uradmin',
  19. 'X-OpenAM-Password: urpassword',
  20. 'Accept-API-Version: resource=2.0, protocol=1.0'
  21. )
  22. );
  23.  
  24. $result = curl_exec($ch);
  25.  
  26. curl_close($ch);
  27.  
  28. if (array_key_exists('tokenId', json_decode($result, true))) {
  29. $adminToke = json_decode($result, true)["tokenId"];
  30.  
  31. //create user in OpenAM Customer Realm
  32. $data = array("username" => $email, "userpassword" => $password,"mail"=>$email);
  33. $data_string = json_encode($data);
  34.  
  35. $ch = curl_init('http://openam/json/admingroup/users/?_action=create');
  36. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  37. curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
  38. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  39. curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  40. 'Content-Type: application/json',
  41. 'iplanetDirectoryPro:'.$adminToke.''
  42. )
  43. );
  44.  
  45.  
  46. curl_close($ch);
  47.  
  48. // create Magento Customer in Magento DB
  49.  
  50.  
  51. $customer=$this->_objectManager->create('MagentoCustomerModelCustomer');
  52. $customer->setWebsiteId($this->_objectManager->create('SupplierDelegateHelperData')->getCurrentWebsiteId());
  53. $customer->setStoreId($this->_objectManager->create('ManufactureDealersHelperData')->getCurrentStoreId());
  54. $customer->setGroupId(5);
  55. $customer->setFirstname($firstName);
  56. $customer->setLastname($lastName);
  57. $customer->setEmail($email);
  58. $customer->setPassword($password);
  59.  
  60.  
  61. try{
  62. $customer->save();
  63. }
  64. catch (Exception $exception)
  65. {
  66. $this->messageManager->addError($exception->getMessage());
  67. return $this->resultRedirectFactory->create()->setPath('*/*/register');
  68. }
  69. //save SupplierDelgate Model
  70. $model = $this->_objectManager->create('ManufactureDealersModelSuppliers');
  71. $model->setDelegateId($customer->getId());
  72. $model->setParentSupplierId($supplierParentId);
  73. $model->setRole($role);
  74. $model->save();
  75.  
  76. $address =$this->_objectManager->create('MagentoCustomerModelAddress');
  77. $address->setCustomerId($customer->getId())
  78. ->setFirstname($customer->getFirstname())
  79. ->setMiddleName($customer->getMiddlename())
  80. ->setLastname($customer->getLastname())
  81. ->setCountryId('SA')
  82. //->setRegionId('1') //state/province, only needed if the country is USA
  83. ->setPostcode($postCode)
  84. ->setCity($city)
  85. ->setTelephone($telephone)
  86. ->setFax($fax)
  87. ->setCompany($company)
  88. ->setStreet($street)
  89. ->setIsDefaultBilling('1')
  90. ->setIsDefaultShipping('1')
  91. ->setSaveInAddressBook('1');
  92.  
  93. try{
  94. $address->save();
  95. $this->_objectManager->create('ManufactureDealersHelperData')->setCustomerStatus("Active",$customer->getId());
  96.  
  97. $this->messageManager->addSuccess(__('registration have been completed Successfully '));
  98. $this->_redirect('customer/account/login/');
  99.  
  100. }
  101. catch (Exception $e) {
  102. Zend_Debug::dump($e->getMessage());
  103. }
  104.  
  105. Fatal error: Uncaught Error: Class 'OauthClient' not found in /public_html/magento2/checklogin.php:22 Stack trace: #0 {main} thrown in /public_html/magento2/checklogin.php on line 22
Add Comment
Please, Sign In to add comment