From b3f27242999100e714b3fe19037dd85e24b06072 Mon Sep 17 00:00:00 2001 From: gonzalo Date: Mon, 11 Nov 2024 12:36:39 -0300 Subject: [PATCH 1/2] closes #2035 for magento 2.4 --- Cron/Ecommerce.php | 20 +++++++++++--------- Helper/Data.php | 13 +++++++++---- etc/adminhtml/system.xml | 8 ++++++++ etc/config.xml | 1 + i18n/es_ES.csv | 1 + i18n/fr_FR.csv | 1 + i18n/it_IT.csv | 1 + view/adminhtml/web/js/configapikey.js | 2 ++ 8 files changed, 34 insertions(+), 13 deletions(-) diff --git a/Cron/Ecommerce.php b/Cron/Ecommerce.php index 2d585ba8..7a3b096c 100644 --- a/Cron/Ecommerce.php +++ b/Cron/Ecommerce.php @@ -205,19 +205,19 @@ protected function _processStore($storeId, $mailchimpStoreId, $listId) $countProducts = 0; $countOrders = 0; $batchArray = []; - $this->_helper->resetCounters(); + $this->_helper->resetCounters($storeId); $results = $this->_apiSubscribers->sendSubscribers($storeId, $listId); if ($this->_helper->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_PATH_ECOMMERCE_ACTIVE, $storeId)) { $this->_helper->log('Generate Products payload'); $products = $this->_apiProduct->_sendProducts($storeId); $countProducts = count($products); $results = array_merge($results, $products); - - $this->_helper->log('Generate Customers payload'); - $customers = $this->_apiCustomer->sendCustomers($storeId); - $countCustomers = count($customers); - $results = array_merge($results, $customers); - + if ($this->_helper->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_PATH_ALL_CUSTOMERS, $storeId)) { + $this->_helper->log('Generate Customers payload'); + $customers = $this->_apiCustomer->sendCustomers($storeId); + $countCustomers = count($customers); + $results = array_merge($results, $customers); + } $this->_helper->log('Generate Orders payload'); $orders = $this->_apiOrder->sendOrders($storeId); $countOrders = count($orders); @@ -261,14 +261,16 @@ protected function _processStore($storeId, $mailchimpStoreId, $listId) $syncBatches->setStatus(\Ebizmarts\MailChimp\Helper\Data::BATCH_PENDING); $syncBatches->setMailchimpStoreId($mailchimpStoreId); $syncBatches->setModifiedDate($this->_helper->getGmtDate()); + if ($this->_helper->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_PATH_ALL_CUSTOMERS, $storeId)) { + $syncBatches->setCustomersNewCount($batchCounters[\Ebizmarts\MailChimp\Helper\Data::CUS_NEW]); + $syncBatches->setCustomersModifiedCount($batchCounters[\Ebizmarts\MailChimp\Helper\Data::CUS_MOD]); + } $syncBatches->setSubscribersNewCount($batchCounters[\Ebizmarts\MailChimp\Helper\Data::SUB_NEW]); $syncBatches->setProductsNewCount($batchCounters[\Ebizmarts\MailChimp\Helper\Data::PRO_NEW]); - $syncBatches->setCustomersNewCount($batchCounters[\Ebizmarts\MailChimp\Helper\Data::CUS_NEW]); $syncBatches->setCartsNewCount($batchCounters[\Ebizmarts\MailChimp\Helper\Data::QUO_NEW]); $syncBatches->setOrdersNewCount($batchCounters[\Ebizmarts\MailChimp\Helper\Data::ORD_NEW]); $syncBatches->setSubscribersModifiedCount($batchCounters[\Ebizmarts\MailChimp\Helper\Data::SUB_MOD]); $syncBatches->setProductsModifiedCount($batchCounters[\Ebizmarts\MailChimp\Helper\Data::PRO_MOD]); - $syncBatches->setCustomersModifiedCount($batchCounters[\Ebizmarts\MailChimp\Helper\Data::CUS_MOD]); $syncBatches->setCartsModifiedCount($batchCounters[\Ebizmarts\MailChimp\Helper\Data::QUO_MOD]); $syncBatches->setOrdersModifiedCount($batchCounters[\Ebizmarts\MailChimp\Helper\Data::ORD_MOD]); $syncBatches->getResource()->save($syncBatches); diff --git a/Helper/Data.php b/Helper/Data.php index e06109cb..d595e10e 100755 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -33,6 +33,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper const XML_PATH_CONFIRMATION_FLAG = 'newsletter/subscription/confirm'; const XML_PATH_STORE = 'mailchimp/ecommerce/store'; const XML_PATH_ECOMMERCE_ACTIVE = 'mailchimp/ecommerce/active'; + const XML_PATH_ALL_CUSTOMERS = 'mailchimp/ecommerce/all_customers'; const XML_PATH_SYNC_DATE = 'mailchimp/general/mcminsyncdateflag'; const XML_ECOMMERCE_OPTIN = 'mailchimp/ecommerce/customer_optin'; const XML_ECOMMERCE_FIRSTDATE = 'mailchimp/ecommerce/firstdate'; @@ -1146,8 +1147,9 @@ public function modifyCounter($index, $increment = 1) $this->counters[$index] = 1; } } - public function resetCounters() + public function resetCounters($storeId = null) { + $this->counters = []; $this->counters = [ self::SUB_NEW => 0, self::SUB_MOD => 0, @@ -1156,12 +1158,15 @@ public function resetCounters() self::PRO_NEW => 0, self::PRO_DELETED => 0, self::PRO_MOD => 0, - self::CUS_NEW => 0, - self::CUS_MOD => 0, self::QUO_NEW => 0, self::QUO_MOD => 0 ]; - } + if ($this->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_PATH_ALL_CUSTOMERS, $storeId)) { + $this->counters [self::CUS_NEW] = 0; + $this->counters [self::CUS_MOD] = 0; + } + + } public function getCounters() { return $this->counters; diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index c21d5ed5..5c56900a 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -193,6 +193,14 @@ Magento\Config\Model\Config\Source\Yesno + + + Magento\Config\Model\Config\Source\Yesno + + + 1 + + Magento\Config\Model\Config\Source\Yesno diff --git a/etc/config.xml b/etc/config.xml index 590d6640..e8997d75 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -5,6 +5,7 @@ sent,open,click + Yes diff --git a/i18n/es_ES.csv b/i18n/es_ES.csv index 32715e8b..ff870ced 100644 --- a/i18n/es_ES.csv +++ b/i18n/es_ES.csv @@ -177,3 +177,4 @@ MC Account name,Nombre de la cuenta de MC Store name,Nombre de la tienda List name,Nombre de la lista Mailchimp Sync,Sincronización de Mailchimp +Sync all customers or only customer with orders, Sincronza todos los clientes o solo los que tienen ordenes diff --git a/i18n/fr_FR.csv b/i18n/fr_FR.csv index 04325ccb..686bbdc9 100644 --- a/i18n/fr_FR.csv +++ b/i18n/fr_FR.csv @@ -177,3 +177,4 @@ MC Account name,Nom du compte MC Store name,Nom de la boutique List name,Nom de la liste Mailchimp Sync,Synchronisation Mailchimp +Sync all customers or only customer with orders,Synchroniser tous les clients ou uniquement les clients avec les commandes diff --git a/i18n/it_IT.csv b/i18n/it_IT.csv index 51a04284..0097de2e 100644 --- a/i18n/it_IT.csv +++ b/i18n/it_IT.csv @@ -177,3 +177,4 @@ MC Account name,Nome account MC Store name,Nome negozio List name,Nome elenco Mailchimp Sync,Sincronizzazione Mailchimp +Sync all customers or only customer with orders,Sincronizza tutti i clienti o solo i clienti con gli ordini diff --git a/view/adminhtml/web/js/configapikey.js b/view/adminhtml/web/js/configapikey.js index 86b0c416..06ddfcb6 100644 --- a/view/adminhtml/web/js/configapikey.js +++ b/view/adminhtml/web/js/configapikey.js @@ -163,6 +163,8 @@ define( $("#row_mailchimp_abandonedcart_create_abandonedcart_automation").hide(); }, _showEcommerce: function () { + $("#row_mailchimp_ecommerce_all_customers").show(); + $("#mailchimp_ecommerce_all_customers").show(); $("#row_mailchimp_ecommerce_customer_optin").show(); $("#mailchimp_ecommerce_customer_optin").show(); $("#row_mailchimp_ecommerce_firstdate").show(); From ad2c280787513a8b748f357e4c37a4b530e2e0b6 Mon Sep 17 00:00:00 2001 From: gonzalo Date: Mon, 11 Nov 2024 13:52:44 -0300 Subject: [PATCH 2/2] closes #2035 for magento 2.4 --- Helper/Data.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Helper/Data.php b/Helper/Data.php index d595e10e..01358eef 100755 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -1166,7 +1166,7 @@ public function resetCounters($storeId = null) $this->counters [self::CUS_MOD] = 0; } - } + } public function getCounters() { return $this->counters;