Skip to content

Commit

Permalink
closes #220
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzaloebiz committed May 31, 2018
1 parent 964eab5 commit 788e0d7
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions Model/Api/PromoRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,21 @@ protected function _getDeletedPromoRules($mailchimpStoreId, $magentoStoreId)
*/
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);
$ruleId = $rule->getData('related_id');
try {
$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);
}
$batchArray[$count]['method'] = 'DELETE';
$batchArray[$count]['path'] = "/ecommerce/stores/$mailchimpStoreId/promo-rules/$ruleId";
$batchArray[$count]['operation_id'] = $this->_batchId . '_' . $ruleId;
$count++;
} catch(\Mailchimp_Error $e) {
$this->_helper->log("The Rule $ruleId is already deleted");
}
$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++;

}
return $batchArray;
}
Expand Down

0 comments on commit 788e0d7

Please sign in to comment.