Skip to content

Commit

Permalink
closes #1640 for magento 2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzaloebiz committed Dec 27, 2022
1 parent 1ceac7a commit bb818a9
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 77 deletions.
22 changes: 2 additions & 20 deletions Controller/Adminhtml/Ecommerce/ResyncProducts.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct(
\Magento\Store\Model\StoreManagerInterface $storeManagerInterface,
\Ebizmarts\MailChimp\Helper\Data $helper
) {

parent::__construct($context);
$this->resultJsonFactory = $resultJsonFactory;
$this->helper = $helper;
Expand All @@ -57,25 +57,7 @@ public function execute()
$valid = 1;
$message = '';
$params = $this->getRequest()->getParams();
if (isset($params['website'])) {
$mailchimpStore = $this->helper->getConfigValue(
\Ebizmarts\MailChimp\Helper\Data::XML_MAILCHIMP_STORE,
$params['website'],
'website'
);
} elseif (isset($params['store'])) {
$mailchimpStore = $this->helper->getConfigValue(
\Ebizmarts\MailChimp\Helper\Data::XML_MAILCHIMP_STORE,
$params['store'],
'store'
);
} else {
$mailchimpStore = $this->helper->getConfigValue(
\Ebizmarts\MailChimp\Helper\Data::XML_MAILCHIMP_STORE,
$this->storeManager->getStore()
);
}

$mailchimpStore = $params['mailchimpStoreId'];
$resultJson = $this->resultJsonFactory->create();
try {
$this->helper->resyncProducts($mailchimpStore);
Expand Down
22 changes: 2 additions & 20 deletions Controller/Adminhtml/Ecommerce/ResyncSubscribers.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct(
\Magento\Store\Model\StoreManagerInterface $storeManagerInterface,
\Ebizmarts\MailChimp\Helper\Data $helper
) {

parent::__construct($context);
$this->resultJsonFactory = $resultJsonFactory;
$this->helper = $helper;
Expand All @@ -57,25 +57,7 @@ public function execute()
$valid = 1;
$message = '';
$params = $this->getRequest()->getParams();
if (isset($params['website'])) {
$mailchimpList = $this->helper->getConfigValue(
\Ebizmarts\MailChimp\Helper\Data::XML_PATH_LIST,
$params['website'],
'website'
);
} elseif (isset($params['store'])) {
$mailchimpList = $this->helper->getConfigValue(
\Ebizmarts\MailChimp\Helper\Data::XML_PATH_LIST,
$params['store'],
'store'
);
} else {
$mailchimpList = $this->helper->getConfigValue(
\Ebizmarts\MailChimp\Helper\Data::XML_PATH_LIST,
$this->storeManager->getStore()
);
}

$mailchimpList = $params['listId'];
$resultJson = $this->resultJsonFactory->create();
try {
$this->helper->resyncAllSubscribers($mailchimpList);
Expand Down
74 changes: 37 additions & 37 deletions view/adminhtml/web/js/configapikey.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ define(
self._createWebhook(apiKey, listId);
});
$('#mailchimp_general_resync_subscribers').click(function () {
var mailchimpStoreId = $('#mailchimp_general_monkeystore').find(':selected').val();
self._resyncSubscribers(mailchimpStoreId);
var listId = $('#mailchimp_general_monkeylist').find(':selected').val();
self._resyncSubscribers(listId);
});
$('#mailchimp_ecommerce_resync_products').click(function () {
var mailchimpStoreId = $('#mailchimp_general_monkeystore').find(':selected').val();
Expand Down Expand Up @@ -85,40 +85,40 @@ define(
},
_changeEcommerce: function () {
var self = this;
confirmation( {
content: "If you disable Ecommerce, we will disable Abandoned Cart",
actions: {
confirm: function () {
var tag = '#mailchimp_abandonedcart_active'
$(tag).empty();
$(tag).append($('<option>', {
value: "0",
text: 'No',
selected: "selected"
}));
$(tag).append($('<option>', {
value: "1",
text: 'Yes'
}));
self._hideAbandonedCart();
},
cancel: function () {
var tag = '#mailchimp_ecommerce_active'
$(tag).empty();
$(tag).append($('<option>', {
value: "0",
text: 'No',
}));
$(tag).append($('<option>', {
value: "1",
text: 'Yes',
selected: "selected"
}));
self._showEcommerce();
}
confirmation( {
content: "If you disable Ecommerce, we will disable Abandoned Cart",
actions: {
confirm: function () {
var tag = '#mailchimp_abandonedcart_active'
$(tag).empty();
$(tag).append($('<option>', {
value: "0",
text: 'No',
selected: "selected"
}));
$(tag).append($('<option>', {
value: "1",
text: 'Yes'
}));
self._hideAbandonedCart();
},
cancel: function () {
var tag = '#mailchimp_ecommerce_active'
$(tag).empty();
$(tag).append($('<option>', {
value: "0",
text: 'No',
}));
$(tag).append($('<option>', {
value: "1",
text: 'Yes',
selected: "selected"
}));
self._showEcommerce();
}
}
}
}
);
);
},
_changeAbandonedCart: function () {
var self = this;
Expand Down Expand Up @@ -236,11 +236,11 @@ define(
}
});
},
_resyncSubscribers: function (mailchimpStoreId) {
_resyncSubscribers: function (listId) {
var resyncSubscribersUrl = this.options.resyncSubscribersUrl;
$.ajax({
url: resyncSubscribersUrl,
data: {'form_key': window.FORM_KEY, 'mailchimpStoreId': mailchimpStoreId},
data: {'form_key': window.FORM_KEY, 'listId': listId},
type: 'GET',
dataType: 'json',
showLoader: true
Expand Down

0 comments on commit bb818a9

Please sign in to comment.