Skip to content

Commit

Permalink
Merge branch 'develop' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Santiagoebizmarts authored Apr 30, 2019
2 parents c0ffad9 + 8901376 commit c5f0a30
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
23 changes: 21 additions & 2 deletions app/code/community/Ebizmarts/MailChimp/Model/Api/Batches.php
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,13 @@ protected function processEachResponseFile($files, $batchId, $mailchimpStoreId)
}
$error = $response->title . " : " . $response->detail;

if ($type == Ebizmarts_MailChimp_Model_Config::IS_PRODUCT) {
$dataProduct = $this->getDataProduct($helper, $mailchimpStoreId, $id, $type);
if ($dataProduct->getMailchimpSyncDeleted() || $dataProduct->getMailchimpSyncError() == Ebizmarts_MailChimp_Model_Api_Products::PRODUCT_DISABLED_IN_MAGENTO) {
$error = Ebizmarts_MailChimp_Model_Api_Products::PRODUCT_DISABLED_IN_MAGENTO;
}
}

$this->saveSyncData($id, $type, $mailchimpStoreId, null, $error, 0, null, null, 0, true);

$mailchimpErrors->setType($response->type);
Expand All @@ -656,7 +663,7 @@ protected function processEachResponseFile($files, $batchId, $mailchimpStoreId)
$mailchimpErrors->save();
$helper->logError($error);
} else {
$syncDataItem = $helper->getEcommerceSyncDataItem($id, $type, $mailchimpStoreId);
$syncDataItem = $this->getDataProduct($helper, $mailchimpStoreId, $id, $type);
if (!$syncDataItem->getMailchimpSyncModified()) {
$this->saveSyncData($id, $type, $mailchimpStoreId, null, null, 0, null, null, 1, true);
}
Expand Down Expand Up @@ -818,7 +825,7 @@ protected function setItemAsModified($helper, $mailchimpStoreId, $id, $type)
{
$isMarkedAsDeleted = null;
if ($type == Ebizmarts_MailChimp_Model_Config::IS_PRODUCT) {
$dataProduct = $helper->getEcommerceSyncDataItem($id, $type, $mailchimpStoreId);
$dataProduct = $this->getDataProduct($helper, $mailchimpStoreId, $id, $type);
$isMarkedAsDeleted = $dataProduct->getMailchimpSyncDeleted();

if (!$isMarkedAsDeleted || $dataProduct->getMailchimpSyncError() != Ebizmarts_MailChimp_Model_Api_Products::PRODUCT_DISABLED_IN_MAGENTO) {
Expand Down Expand Up @@ -853,4 +860,16 @@ protected function shouldFlagAsSynced($syncingFlag, $itemAmount)
{
return ($syncingFlag === '1' || $syncingFlag === null) && $itemAmount === 0;
}

/**
* @param $helper
* @param $mailchimpStoreId
* @param $id
* @param $type
* @return Varien_Object
*/
protected function getDataProduct($helper, $mailchimpStoreId, $id, $type)
{
return $helper->getEcommerceSyncDataItem($id, $type, $mailchimpStoreId);
}
}
3 changes: 2 additions & 1 deletion app/code/community/Ebizmarts/MailChimp/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,8 @@ public function productSaveAfter(Varien_Event_Observer $observer)
if ($status[$product->getId()] == self::PRODUCT_IS_ENABLED) {
$dataProduct = $helper->getEcommerceSyncDataItem($product->getId(), Ebizmarts_MailChimp_Model_Config::IS_PRODUCT, $mailchimpStoreId);
$isMarkedAsDeleted = $dataProduct->getMailchimpSyncDeleted();
if ($isMarkedAsDeleted) {
$errorMessage = $dataProduct->getMailchimpSyncError();
if ($isMarkedAsDeleted || $errorMessage == Ebizmarts_MailChimp_Model_Api_Products::PRODUCT_DISABLED_IN_MAGENTO) {
$dataProduct->delete();
} else {
$apiProduct->update($product->getId(), $mailchimpStoreId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1226,7 +1226,7 @@ public function testProductSaveAfter()
->getMock();

$storeMock = $this->getMockBuilder(ArrayObject::class)
->setMethods(array())
->setMethods(array('getIterator'))
->getMock();

$eventObserverMock = $this->getMockBuilder(Varien_Event::class)
Expand Down

0 comments on commit c5f0a30

Please sign in to comment.