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

ebizmarts_ecommerce has an error #767

Closed
vDeggial opened this issue Jun 20, 2019 · 10 comments
Closed

ebizmarts_ecommerce has an error #767

vDeggial opened this issue Jun 20, 2019 · 10 comments
Assignees
Milestone

Comments

@vDeggial
Copy link

Magento 2.2.8
Mailchimp: v101.2.36
For last few hours this has been happening and nothing is synced to Mailchimp:

[2019-06-20 00:15:26] main.ERROR: Cron Job ebizmarts_ecommerce has an error: Warning: Invalid argument supplied for foreach() in /home/jri/public_html/vendor/mailchimp/mc-magento2/Helper/Data.php on line 1037. Statistics: {"sum":0,"count":1,"realmem":0,"emalloc":0,"realmem_start":134217728,"emalloc_start":128640120} [] []
[2019-06-20 00:15:26] main.CRITICAL: Warning: Invalid argument supplied for foreach() in /home/jri/public_html/vendor/mailchimp/mc-magento2/Helper/Data.php on line 1037 {"exception":"[object] (Exception(code: 0): Warning: Invalid argument supplied for foreach() in /home/jri/public_html/vendor/mailchimp/mc-magento2/Helper/Data.php on line 1037 at /home/jri/public_html/vendor/magento/framework/App/ErrorHandler.php:61)"} []

The problem indicates that issue is around the lines of:

$api = $this->getApi($storeId);
            $listId = $this->getConfigValue(self::XML_PATH_LIST, $storeId);
            $allInterest = $api->lists->interestCategory->getAll($listId);
            foreach ($allInterest['categories'] as $item) {
                if (in_array($item['id'], $interest)) {
                    $rc[$item['id']]['interest'] = ['id' => $item['id'], 'title' => $item['title'], 'type' => $item['type']];
                }
            }

which maybe tells that there is an issue with API ... or the plugin (which have not been changed in any way)

@vDeggial
Copy link
Author

It seems that only Orders sync is affected, Subscribers seem to be syncing fine ...

@gonzaloebiz
Copy link
Collaborator

Try to put the foreach that way:

            if (array_key_exists('categories',$allInterest) && is_array($allInterest['categories'])) {
                foreach ($allInterest['categories'] as $item) {
                    if (in_array($item['id'], $interest)) {
                        $rc[$item['id']]['interest'] = ['id' => $item['id'], 'title' => $item['title'], 'type' => $item['type']];
                    }
                }
            }


@vDeggial
Copy link
Author

That gives a new error:

 [2019-06-20 19:06:01] main.ERROR: Cron Job ebizmarts_ecommerce has an error: Warning: array_key_exists() expects parameter 2 to be array, null given in /home/jri/public_html/vendor/mailchimp/mc-magento2/Helper/Data.php on line 1037. Statistics: {"sum":0,"count":1,"realmem":0,"emalloc":0,"realmem_start":153092096,"emalloc_start":146238200} [] []
[2019-06-20 19:06:01] main.CRITICAL: Warning: array_key_exists() expects parameter 2 to be array, null given in /home/jri/public_html/vendor/mailchimp/mc-magento2/Helper/Data.php on line 1037 {"exception":"[object] (Exception(code: 0): Warning: array_key_exists() expects parameter 2 to be array, null given in /home/jri/public_html/vendor/mailchimp/mc-magento2/Helper/Data.php on line 1037 at /home/jri/public_html/vendor/magento/framework/App/ErrorHandler.php:61)"} []

@gonzaloebiz
Copy link
Collaborator

gonzaloebiz commented Jun 20, 2019

Is so weird, what if you use curl from the command line like say here?

https://developer.mailchimp.com/documentation/mailchimp/reference/lists/interest-categories/#read-get_lists_list_id_interest_categories

specifying your list of course

@vDeggial
Copy link
Author

image

image

@gonzaloebiz
Copy link
Collaborator

perhaps a cache issue?
Change this line https://github.com/ebizmarts/mailchimp-lib/blob/master/src/Mailchimp.php#L226 for this

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Cache-Control: no-cache'));

@vDeggial
Copy link
Author

still same error after that change :( Could it be related to Godaddy VPS screwing things up again (they did before with dif issue and we had to rebuild the server as they didnt want to help)? It just randomly started yesterday afternoon ...

@vDeggial
Copy link
Author

I commented out that code in Data.php that gave errors (it relates to list intersts anyways which we dont have) and all syncing fine now lol

/*
            $api = $this->getApi($storeId);
            $listId = $this->getConfigValue(self::XML_PATH_LIST, $storeId);
            $allInterest = $api->lists->interestCategory->getAll($listId);
            if (array_key_exists('categories',$allInterest) && is_array($allInterest['categories'])) {
                foreach ($allInterest['categories'] as $item) {
                    if (in_array($item['id'], $interest)) {
                        $rc[$item['id']]['interest'] = ['id' => $item['id'], 'title' => $item['title'], 'type' => $item['type']];
                    }
                }
            }
            foreach ($interest as $interestId) {
                $mailchimpInterest = $api->lists->interestCategory->interests->getAll($listId, $interestId);
                foreach ($mailchimpInterest['interests'] as $mi) {
                    $rc[$mi['category_id']]['category'][$mi['display_order']] = ['id' => $mi['id'], 'name' => $mi['name'], 'checked' => false];
                }
            } */

@vDeggial
Copy link
Author

upon upgrade to Magento 2.2.9 and reinstalling the plugin all works fine without the modification ... weird :(

@gonzaloebiz
Copy link
Collaborator

Weird!!!
I close the issue, i will re open if you have any problem

Best

gonzaloebiz added a commit that referenced this issue Jul 5, 2019
@gonzaloebiz gonzaloebiz added this to the 10x.x.37 milestone Jul 8, 2019
@gonzaloebiz gonzaloebiz added the bug label Jul 8, 2019
@gonzaloebiz gonzaloebiz self-assigned this Jul 8, 2019
gonzaloebiz added a commit that referenced this issue Jul 8, 2019
gonzaloebiz added a commit that referenced this issue Jul 8, 2019
gonzaloebiz added a commit that referenced this issue Jul 8, 2019
gonzaloebiz added a commit that referenced this issue Jul 8, 2019
gonzaloebiz added a commit that referenced this issue Jul 8, 2019
gonzaloebiz added a commit that referenced this issue Aug 16, 2019
gonzaloebiz added a commit that referenced this issue Aug 16, 2019
gonzaloebiz added a commit that referenced this issue Aug 16, 2019
gonzaloebiz added a commit that referenced this issue Aug 16, 2019
gonzaloebiz added a commit that referenced this issue Aug 16, 2019
gonzaloebiz added a commit that referenced this issue Aug 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants