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

Exception is thrown when Promotion is marked for removal #280

Closed
gregor-RW opened this issue Apr 16, 2018 · 2 comments
Closed

Exception is thrown when Promotion is marked for removal #280

gregor-RW opened this issue Apr 16, 2018 · 2 comments
Milestone

Comments

@gregor-RW
Copy link

gregor-RW commented Apr 16, 2018

Looking at the code of \Ebizmarts\MailChimp\Model\Api\PromoRules::_getDeletedPromoRules
there is a bug. The collection that is created, is a syncCollection (\Ebizmarts\MailChimp\Model\ResourceModel\MailChimpSyncEcommerce\Collection). Few lines lower, $ruleId is fetched from $rule->getRuleId() and $rule is commented as \Magento\SalesRule\Model\Rule which is not true. The collection returns \Ebizmarts\MailChimp\Model\ResourceModel\MailChimpSyncEcommerce objects, not \Magento\SalesRule\Model\Rule.

fixed code looks like this:

    foreach($collection as $rule)
    {
        $ruleId = $rule->getData('related_id');
        $mailchimpRule = $api->ecommerce->promoCodes->getAll($mailchimpStoreId,$ruleId);
        foreach($mailchimpRule['promo_codes'] as $promoCode)
        {
            $this->_helper->ecommerceDeleteAllByIdType($promoCode['id'], \Ebizmarts\MailChimp\Helper\Data::IS_PROMO_CODE);
        }
        $this->_helper->ecommerceDeleteAllByIdType($ruleId, \Ebizmarts\MailChimp\Helper\Data::IS_PROMO_RULE);
        $batchArray[$count]['method'] = 'DELETE';
        $batchArray[$count]['path'] = "/ecommerce/stores/$mailchimpStoreId/promo-rules/$ruleId";
        $batchArray[$count]['operation_id'] = $this->_batchId. '_' . $ruleId;
        $count++;
    }
@gregor-RW
Copy link
Author

Attaching patch we used.
mailchimp_promo_rules_patch.patch.txt

@gundamkid
Copy link
Contributor

Thank you @gregorRW , I got this error too 👍

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

3 participants