Skip to content

Exception is thrown when Promotion is marked for removal #280

Closed
@gregor-RW

Description

@gregor-RW

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++;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions