Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resync subscribers and Resync products always resyncs default store #1640

Closed
MProvii opened this issue Dec 23, 2022 · 0 comments · Fixed by #1641, #1642, #1643, #1644 or #1645
Closed

Resync subscribers and Resync products always resyncs default store #1640

MProvii opened this issue Dec 23, 2022 · 0 comments · Fixed by #1641, #1642, #1643, #1644 or #1645

Comments

@MProvii
Copy link

MProvii commented Dec 23, 2022

Description

When having multiple audiences and multiple stores assigned to the Mailchimp integration always the default list is marked to resync.

Steps to reproduce:

  1. Magento CE 2.3.4-p2 but it happens with all editions.
  2. mc-magento2 102.3.50
  3. Create two stores in Magento.
  4. Create one mailchimp store.
  5. Configure the not default store by store view, not website. Because if not, the module will take the default values.
  6. Sync some subscribers or products and try to resync them.
  7. The modified field is not changed in DB.

Actual result and expected result

Actual result: The subscribers or products are not marked to resync unless they are the default list.
Expected result: The subscribers or products are marked to resync despite of the store view configuration.

Additional information

The problem can be fixed by modifying the following files and functions:

  • Ebizmarts/MailChimp/view/adminhtml/web/js/configapikey.js. The functions _resyncSubscribers and _resyncProducts miss the parameters scope and scopeId as in the other functions.
  • Ebizmarts/MailChimp/Controller/Adminhtml/Ecommerce/ResyncProducts.php. The function execute needs to retrieve the params scope and scopeId, instead of the params website or store (which do not exist).
    • Ebizmarts/MailChimp/Controller/Adminhtml/Ecommerce/ResyncSubscribers.php. The function execute needs to retrieve the params scope and scopeId, instead of the params website or store (which do not exist).

Code of Ebizmarts/MailChimp/view/adminhtml/web/js/configapikey.js.

          _resyncSubscribers: function (mailchimpStoreId) {
              var resyncSubscribersUrl = this.options.resyncSubscribersUrl;
              var scope = this.options.scope;
              var scopeId = this.options.scopeId;
              $.ajax({
                  url: resyncSubscribersUrl,
                  data: {'form_key': window.FORM_KEY, 'mailchimpStoreId': mailchimpStoreId, 'scope': scope, 'scopeId': scopeId},
                  type: 'GET',
                  dataType: 'json',
                  showLoader: true
              }).done(function (data) {
                  if (data.valid == 0) {
                      alert({content: 'Error: can\'t resync your subscribers'});
                  } else if (data.valid == 1) {
                      alert({content: 'All subscribers marked for resync'});
                  }
              });
          },
          _resyncProducts: function (mailchimpStoreId) {
              var resyncProductsUrl = this.options.resyncProductsUrl;
              var scope = this.options.scope;
              var scopeId = this.options.scopeId;
              $.ajax({
                  url: resyncProductsUrl,
                  data: {'form_key': window.FORM_KEY, 'mailchimpStoreId': mailchimpStoreId, 'scope': scope, 'scopeId': scopeId},
                  type: 'GET',
                  dataType: 'json',
                  showLoader: true
              }).done(function (data) {
                  if (data.valid == 0) {
                      alert({content: 'Error: can\'t resync your products'});
                  } else if (data.valid == 1) {
                      alert({content: 'All products marked for resync'});
                  }
              });
          },

Code of Ebizmarts/MailChimp/Controller/Adminhtml/Ecommerce/ResyncProducts.php

        $params = $this->getRequest()->getParams();
        if (isset($params['scope']) && isset($params['scopeId'])
            && ($params['scope'] == 'website' || $params['scope'] == 'store')) {
            $mailchimpList = $this->helper->getConfigValue(
                \Ebizmarts\MailChimp\Helper\Data::XML_PATH_LIST,
                $params['scopeId'],
                $params['scope']
            );
        }
        else {
            $mailchimpStore = $this->helper->getConfigValue(
                \Ebizmarts\MailChimp\Helper\Data::XML_MAILCHIMP_STORE,
                $this->storeManager->getStore()
            );
        }
gonzaloebiz added a commit that referenced this issue Dec 27, 2022
gonzaloebiz added a commit that referenced this issue Dec 27, 2022
gonzaloebiz added a commit that referenced this issue Dec 27, 2022
gonzaloebiz added a commit that referenced this issue Dec 27, 2022
gonzaloebiz added a commit that referenced this issue Dec 27, 2022
@gonzaloebiz gonzaloebiz self-assigned this Dec 27, 2022
@gonzaloebiz gonzaloebiz added this to the 10x.x.51 milestone Dec 27, 2022
gonzaloebiz added a commit that referenced this issue Dec 27, 2022
gonzaloebiz added a commit that referenced this issue Dec 27, 2022
gonzaloebiz added a commit that referenced this issue Dec 27, 2022
gonzaloebiz added a commit that referenced this issue Dec 27, 2022
gonzaloebiz added a commit that referenced this issue Dec 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment