/**
  * Refresh suppressed contacts.
  */
 public function execute()
 {
     $result = $this->cronFactory->create()->orderSync();
     $this->messageManager->addSuccessMessage($result['message']);
     $redirectUrl = $this->getUrl('adminhtml/system_config/edit', ['section' => 'connector_developer_settings']);
     $this->_redirect($redirectUrl);
 }
 /**
  * Refresh suppressed contacts.
  */
 public function execute()
 {
     $result = $this->importerFactory->create()->processQueue();
     $this->messageManager->addSuccessMessage($result['message']);
     $redirectBack = $this->_redirect->getRefererUrl();
     $this->_redirect($redirectBack);
 }
 /**
  * Refresh suppressed contacts.
  */
 public function execute()
 {
     $this->catalogFactory->create()->resetCatalog();
     $this->messageManager->addSuccessMessage(__('Done.'));
     $redirectUrl = $this->getUrl('adminhtml/system_config/edit', ['section' => 'connector_developer_settings']);
     $this->_redirect($redirectUrl);
 }
 /**
  * Refresh suppressed contacts.
  */
 public function execute()
 {
     $result = $this->cronFactory->create()->contactSync();
     $this->messageManager->addSuccessMessage($result['message']);
     $redirectBack = $this->_redirect->getRefererUrl();
     $this->_redirect($redirectBack);
 }
 /**
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function execute()
 {
     $redirectUrl = $this->getUrl('adminhtml/system_config/edit', ['section' => 'connector_developer_settings']);
     $result = $this->contactFactory->create()->deleteContactIds();
     $this->messageManager->addSuccessMessage('Contact id\'s reseted ' . $result);
     $this->_redirect($redirectUrl);
 }
 /**
  * Execute method.
  *
  * @param \Magento\Framework\Event\Observer $observer
  *
  * @return $this
  * @codingStandardsIgnoreStart
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     //@codingStandardsIgnoreEnd
     $groups = $this->context->getRequest()->getPost('groups');
     if (isset($groups['api']['fields']['username']['inherit']) || isset($groups['api']['fields']['password']['inherit'])) {
         return $this;
     }
     $apiUsername = isset($groups['api']['fields']['username']['value']) ? $groups['api']['fields']['username']['value'] : false;
     $apiPassword = isset($groups['api']['fields']['password']['value']) ? $groups['api']['fields']['password']['value'] : false;
     //skip if the inherit option is selected
     if ($apiUsername && $apiPassword) {
         $this->helper->log('----VALIDATING ACCOUNT---');
         $isValid = $this->test->validate($apiUsername, $apiPassword);
         if ($isValid) {
             //save endpoint for account
             foreach ($isValid->properties as $property) {
                 if ($property->name == 'ApiEndpoint' && !empty($property->value)) {
                     $this->saveApiEndpoint($property->value);
                     break;
                 }
             }
             $this->messageManager->addSuccessMessage(__('API Credentials Valid.'));
         } else {
             $this->messageManager->addWarningMessage(__('Authorization has been denied for this request.'));
         }
     }
     return $this;
 }
 /**
  * Execute method.
  */
 public function execute()
 {
     $datafield = $this->getRequest()->getParam('name');
     $type = $this->getRequest()->getParam('type');
     $default = $this->getRequest()->getParam('default');
     $visibility = $this->getRequest()->getParam('visibility');
     $website = $this->getRequest()->getParam('website', 0);
     $client = $this->dataHelper->getWebsiteApiClient($website);
     if (!empty($datafield)) {
         $response = $client->postDataFields($datafield, $type, $visibility, $default);
         if (isset($response->message)) {
             $this->messageManager->addErrorMessage($response->message);
         } else {
             $this->messageManager->addSuccessMessage('Datafield : ' . $datafield . ' created.');
         }
     }
 }
 /**
  * Execute method.
  */
 public function execute()
 {
     $addressBookName = $this->getRequest()->getParam('name');
     $visibility = $this->getRequest()->getParam('visibility');
     $website = $this->getRequest()->getParam('website', 0);
     if ($this->helperData->isEnabled($website)) {
         $client = $this->helperData->getWebsiteApiClient($website);
         if (!empty($addressBookName)) {
             $response = $client->postAddressBooks($addressBookName, $visibility);
             if (isset($response->message)) {
                 $this->messageManager->addErrorMessage($response->message);
             } else {
                 $this->messageManager->addSuccessMessage('Address book : ' . $addressBookName . ' created.');
             }
         }
     }
 }
 /**
  * Execute method.
  */
 public function execute()
 {
     $result = ['errors' => false, 'message' => ''];
     $website = $this->getRequest()->getParam('website', 0);
     $client = false;
     if ($this->data->isEnabled()) {
         $client = $this->data->getWebsiteApiClient($website);
     }
     $redirectUrl = $this->getUrl('adminhtml/system_config/edit', ['section' => 'connector_developer_settings']);
     if (!$client) {
         $this->messageManager->addNoticeMessage('Please enable api first.');
     } else {
         // get all possible datatifileds
         $datafields = $this->datafield->getContactDatafields();
         foreach ($datafields as $key => $datafield) {
             $response = $client->postDataFields($datafield);
             //ignore existing datafields message
             if (isset($response->message) && $response->message != \Dotdigitalgroup\Email\Model\Apiconnector\Client::API_ERROR_DATAFIELD_EXISTS) {
                 $result['errors'] = true;
                 $result['message'] .= ' Datafield ' . $datafield['name'] . ' - ' . $response->message . '</br>';
             } else {
                 if ($website) {
                     $scope = 'websites';
                     $scopeId = $website;
                 } else {
                     $scope = 'default';
                     $scopeId = '0';
                 }
                 /*
                  * map the succesful created datafield
                  */
                 $this->data->saveConfigData('connector_data_mapping/customer_data/' . $key, strtoupper($datafield['name']), $scope, $scopeId);
                 $this->data->log('successfully connected : ' . $datafield['name']);
             }
         }
         if ($result['errors']) {
             $this->messageManager->addNoticeMessage($result['message']);
         } else {
             $this->messageManager->addSuccessMessage('All Datafields Created And Mapped.');
         }
     }
     $this->_redirect($redirectUrl);
 }
 /**
  * Append message to the customer session to inform he has been redirected
  *
  * @param \Magento\Catalog\Api\Data\ProductInterface $product The product being redirected to.
  */
 private function addRedirectMessage(ProductInterface $product)
 {
     $message = __("%1 is the only product matching your '%2' research.", $product->getName(), $this->helper->getEscapedQueryText());
     $this->messageManager->addSuccessMessage($message);
 }