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

Ecommerce orders deadlock issue 1175 #1178

Merged
merged 10 commits into from
May 26, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ protected function addSyncDataToken($id, $token)

protected function markSyncDataAsModified($id)
{
$this->_updateSyncData($id, null, null, 1);
$this->_updateSyncData($id, null, null, 1, null, null, null, true);
}

protected function markSyncDataAsDeleted($id, $syncedFlag = null)
Expand Down
39 changes: 22 additions & 17 deletions app/code/community/Ebizmarts/MailChimp/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,27 +440,32 @@ public function newOrder(Varien_Event_Observer $observer)
$this->removeCampaignData();
$items = $order->getAllItems();

foreach ($items as $item) {
if ($this->isBundleItem($item) || $this->isConfigurableItem($item)) {
continue;
}
try {
foreach ($items as $item) {
if ($this->isBundleItem($item) || $this->isConfigurableItem($item)) {
continue;
}

$mailchimpStoreId = $helper->getMCStoreId($storeId);
$productId = $item->getProductId();
$dataProduct = $this->getMailchimpEcommerceSyncDataModel()->getEcommerceSyncDataItem(
$productId,
Ebizmarts_MailChimp_Model_Config::IS_PRODUCT,
$mailchimpStoreId
);
$mailchimpStoreId = $helper->getMCStoreId($storeId);
$productId = $item->getProductId();
$dataProduct = $this->getMailchimpEcommerceSyncDataModel()->getEcommerceSyncDataItem(
$productId,
Ebizmarts_MailChimp_Model_Config::IS_PRODUCT,
$mailchimpStoreId
);

$isMarkedAsDeleted = $dataProduct->getMailchimpSyncDeleted();
$isMarkedAsDeleted = $dataProduct->getMailchimpSyncDeleted();
$isMarkedAsModified = $dataProduct->getMailchimpSyncModified();

if (!$isMarkedAsDeleted) {
$apiProducts = $this->makeApiProduct();
$apiProducts->setMailchimpStoreId($mailchimpStoreId);
$apiProducts->setMagentoStoreId($storeId);
$apiProducts->update($productId);
if (!$isMarkedAsDeleted && !$isMarkedAsModified) {
$apiProducts = $this->makeApiProduct();
$apiProducts->setMailchimpStoreId($mailchimpStoreId);
$apiProducts->setMagentoStoreId($storeId);
$apiProducts->update($productId);
}
}
} catch (Exception $e) {
$helper->logError($e->getMessage());
}
}

Expand Down