diff --git a/Model/Api/Customer.php b/Model/Api/Customer.php index 4be315e2..6d90093d 100644 --- a/Model/Api/Customer.php +++ b/Model/Api/Customer.php @@ -256,7 +256,10 @@ protected function _updateCustomer($storeId, $entityId, $sync_delta = null, $syn \Ebizmarts\MailChimp\Helper\Data::IS_CUSTOMER, $sync_delta, $sync_error, - $sync_modified + $sync_modified, + null, + null, + \Ebizmarts\MailChimp\Helper\Data::WAITINGSYNC ); } } diff --git a/Ui/Component/Listing/Column/Customers.php b/Ui/Component/Listing/Column/Customers.php new file mode 100644 index 00000000..dc448e96 --- /dev/null +++ b/Ui/Component/Listing/Column/Customers.php @@ -0,0 +1,165 @@ +_requestInterface = $requestInterface; + $this->_assetRepository = $assetRepository; + $this->_customerFactory = $customerFactory; + $this->_helper = $helper; + $this->_mailChimpErrorsFactory = $mailChimpErrorsFactory; + parent::__construct($context, $uiComponentFactory, $components, $data); + } + + public function prepareDataSource(array $dataSource) + { + if (isset($dataSource['data']['items'])) { + $params = ['_secure' => $this->_requestInterface->isSecure()]; + foreach ($dataSource['data']['items'] as & $item) { + /** + * @var $customer \Magento\Customer\Model\Customer + */ + $customer = $this->_customerFactory->create()->load($item['entity_id']); + $params = ['_secure' => $this->_requestInterface->isSecure()]; + $alt = ''; + if ($this->_helper->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_PATH_ACTIVE, $customer->getStoreId())) { + $mailchimpStoreId = $this->_helper->getConfigValue( + \Ebizmarts\MailChimp\Helper\Data::XML_MAILCHIMP_STORE, + $customer->getStoreId() + ); + $syncData = $this->_helper->getChimpSyncEcommerce( + $mailchimpStoreId, + $customer->getId(), + \Ebizmarts\MailChimp\Helper\Data::IS_CUSTOMER + ); + if (!$syncData || $syncData->getMailchimpStoreId() != $mailchimpStoreId || + $syncData->getRelatedId() != $customer->getId() || + $syncData->getType() != \Ebizmarts\MailChimp\Helper\Data::IS_CUSTOMER) { + $url = $this->_assetRepository->getUrlWithParams( + 'Ebizmarts_MailChimp::images/no.png', + $params + ); + $text = __('Syncing'); + } else { + $sync = $syncData->getMailchimpSent(); + switch ($sync) { + case \Ebizmarts\MailChimp\Helper\Data::SYNCED: + $url = $this->_assetRepository->getUrlWithParams( + 'Ebizmarts_MailChimp::images/yes.png', + $params + ); + $text = __('Synced'); + $alt = $syncData->getMailchimpSyncDelta(); + break; + case \Ebizmarts\MailChimp\Helper\Data::WAITINGSYNC: + $url = $this->_assetRepository->getUrlWithParams( + 'Ebizmarts_MailChimp::images/waiting.png', + $params + ); + $text = __('Waiting'); + $alt = $syncData->getMailchimpSyncDelta(); + break; + case \Ebizmarts\MailChimp\Helper\Data::SYNCERROR: + $url = $this->_assetRepository->getUrlWithParams( + 'Ebizmarts_MailChimp::images/error.png', + $params + ); + $text = __('Error'); + $customerError = $this->_getError($customer->getId(), $customer->getStoreId()); + if ($customerError) { + $alt = $customerError->getErrors(); + } + break; + case \Ebizmarts\MailChimp\Helper\Data::NEEDTORESYNC: + $url = $this->_assetRepository->getUrlWithParams( + 'Ebizmarts_MailChimp::images/resync.png', + $params + ); + $text = __('Resyncing'); + $alt = $syncData->getMailchimpSyncDelta(); + break; + case \Ebizmarts\MailChimp\Helper\Data::NOTSYNCED: + $url = $this->_assetRepository->getUrlWithParams( + 'Ebizmarts_MailChimp::images/never.png', + $params + ); + $text = __('With error'); + $alt = $syncData->getMailchimpSyncError(); + break; + default: + $url = $this->_assetRepository->getUrlWithParams( + 'Ebizmarts_MailChimp::images/error.png', + $params + ); + $text = __('Error'); + } + + } + + } + $item['mailchimp_sync'] = + "