Skip to content

Commit

Permalink
Merge pull request #646 from mailchimp/missing-check
Browse files Browse the repository at this point in the history
Add missing check.
  • Loading branch information
Santiagoebizmarts authored Feb 21, 2018
2 parents b42ba7c + e2a5556 commit ed49076
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions app/code/community/Ebizmarts/MailChimp/Model/Api/Batches.php
Original file line number Diff line number Diff line change
Expand Up @@ -707,25 +707,30 @@ protected function saveSyncData($itemId, $itemType, $mailchimpStoreId, $syncDelt
protected function addSyncValueToArray($storeId, $syncedDateArray)
{
$helper = $this->getHelper();
$mailchimpStoreId = $helper->getMCStoreId($storeId);
$syncedDate = $helper->getMCIsSyncing($storeId);
// Check if $syncedDate is in date format to support previous versions.
if (isset($syncedDateArray[$mailchimpStoreId]) && $syncedDateArray[$mailchimpStoreId]) {
if ($helper->validateDate($syncedDate)) {
if ($syncedDate > $syncedDateArray[$mailchimpStoreId]) {
$syncedDateArray[$mailchimpStoreId] = array($storeId => $syncedDate);
$ecomEnabled = $helper->isEcomSyncDataEnabled($storeId);

if ($ecomEnabled) {
$mailchimpStoreId = $helper->getMCStoreId($storeId);
$syncedDate = $helper->getMCIsSyncing($storeId);

// Check if $syncedDate is in date format to support previous versions.
if (isset($syncedDateArray[$mailchimpStoreId]) && $syncedDateArray[$mailchimpStoreId]) {
if ($helper->validateDate($syncedDate)) {
if ($syncedDate > $syncedDateArray[$mailchimpStoreId]) {
$syncedDateArray[$mailchimpStoreId] = array($storeId => $syncedDate);
}
} elseif ((int)$syncedDate === 1) {
$syncedDateArray[$mailchimpStoreId] = array($storeId => false);
}
} elseif ((int)$syncedDate === 1) {
$syncedDateArray[$mailchimpStoreId] = array($storeId => false);
}
} else {
if ($helper->validateDate($syncedDate)) {
$syncedDateArray[$mailchimpStoreId] = array($storeId => $syncedDate);
} else {
if ((int)$syncedDate === 1) {
$syncedDateArray[$mailchimpStoreId] = array($storeId => false);
} elseif (!isset($syncedDateArray[$mailchimpStoreId])) {
$syncedDateArray[$mailchimpStoreId] = array($storeId => true);
if ($helper->validateDate($syncedDate)) {
$syncedDateArray[$mailchimpStoreId] = array($storeId => $syncedDate);
} else {
if ((int)$syncedDate === 1) {
$syncedDateArray[$mailchimpStoreId] = array($storeId => false);
} elseif (!isset($syncedDateArray[$mailchimpStoreId])) {
$syncedDateArray[$mailchimpStoreId] = array($storeId => true);
}
}
}
}
Expand Down

0 comments on commit ed49076

Please sign in to comment.