public function execute(\Magento\Framework\Event\Observer $observer) { $activationHelper = $this->_objectManager->get('LoginRadius\\Activation\\Model\\Helper\\Data'); $customerRegistrationHelper = $this->_objectManager->get("LoginRadius" . "\\" . $activationHelper->getAuthDirectory() . "\\Model\\Helper\\Data"); if ($customerRegistrationHelper->enableRaas() != '1') { return; } $customer = $observer->getEvent()->getCustomer(); $customerId = $customer->getId(); $resource = $this->_objectManager->get('Magento\\Framework\\App\\ResourceConnection'); $changelogName = $resource->getTableName('lr_sociallogin'); $connection = $resource->getConnection(); $select = $connection->select()->from(['r' => $changelogName])->where('entity_id=?', $customerId); $output = $connection->fetchAll($select); /* Delete raas profile from local db */ $accountAPI = new \LoginRadiusSDK\CustomerRegistration\AccountAPI($activationHelper->siteApiKey(), $activationHelper->siteApiSecret(), array('authentication' => true, 'output_format' => 'json')); try { $output[0]['uid'] = isset($output[0]['uid']) ? $output[0]['uid'] : ''; if (!empty($output[0]['uid'])) { $userRaasDelete = $accountAPI->deleteAccount($output[0]['uid']); $changelogName = $resource->getTableName('lr_sociallogin'); $connection = $resource->getConnection(); $where = array("entity_id =" . $customerId); $connection->delete($changelogName, $where); } } catch (\LoginRadiusSDK\LoginRadiusException $e) { } }
public function delete_before_customer($observer) { require_once Mage::getModuleDir('', 'Loginradius_Sociallogin') . DS . 'Helper' . DS . 'SDKClient.php'; global $apiClient_class; $apiClient_class = 'Loginradius_Sociallogin_Helper_SDKClient'; $activationBlockObj = Mage::getBlockSingleton('activation/activation'); $accountAPI = new LoginRadiusSDK\CustomerRegistration\AccountAPI($activationBlockObj->apiKey(), $activationBlockObj->apiSecret(), array('output_format' => 'json')); $postData = Mage::app()->getRequest()->getPost(); $isError = ''; if (isset($postData['customer']) && is_array($postData['customer'])) { $loginRadiusConn = Mage::getSingleton('core/resource')->getConnection('core_read'); foreach ($postData['customer'] as $customerId) { $loginRadiusQuery = "select uid from " . Mage::getSingleton('core/resource')->getTableName('lr_sociallogin') . " where entity_id = '" . $customerId . "' LIMIT 1"; $loginRadiusQueryHandle = $loginRadiusConn->query($loginRadiusQuery); $loginRadiusResult = $loginRadiusQueryHandle->fetch(); if (isset($loginRadiusResult['uid']) && !empty($loginRadiusResult['uid'])) { $response = $accountAPI->deleteAccount($loginRadiusResult['uid']); if (isset($response->description)) { $isError = $response->description; } else { $isError = ''; } } unset($loginRadiusResult['uid']); } } }