Skip to content

Commit

Permalink
Fixes and methods moved
Browse files Browse the repository at this point in the history
  • Loading branch information
giorello committed Oct 14, 2020
1 parent 2732eb6 commit 63dd9fe
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 41 deletions.
38 changes: 6 additions & 32 deletions app/code/community/Ebizmarts/MailChimp/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -1972,36 +1972,10 @@ public function retrieveAndSaveMCJsUrlInConfig($scopeId, $scope = 'stores')
return $mcJsUrlSaved;
}

/**
* @param $collection
*/
public function _loadItemCollection($collection)
{
$collection->load();
}

/**
* Modify is_syncing value if initial sync finished for all stores.
*
* @param $syncValue
*/
public function _setIsSyncingIfFinishedInAllStores($syncValue)
{
$stores = $this->getMageApp()->getStores();

foreach ($stores as $storeId => $store) {
$ecommEnabled = $this->isEcomSyncDataEnabled($storeId);

if ($ecommEnabled) {
$this->setIsSyncingIfFinishedPerScope($syncValue, $storeId);
}
}
}

/**
* @return Ebizmarts_MailChimp_Helper_Webhook
*/
public function getWebhookHelper()
protected function getWebhookHelper()
{
return Mage::helper('mailchimp/webhook');
}
Expand Down Expand Up @@ -3828,15 +3802,15 @@ public function isAdmin()
/**
* @return Ebizmarts_MailChimp_Model_Interestgroup
*/
public function getInterestGroupModel()
protected function getInterestGroupModel()
{
return Mage::getModel('mailchimp/interestgroup');
}

/**
* @return Mage_Customer_Model_Session
*/
public function getCustomerSession()
protected function getCustomerSession()
{
return Mage::getSingleton('customer/session');
}
Expand Down Expand Up @@ -3967,7 +3941,7 @@ public function isInterestGroupEnabled($scopeId = 0, $scope = null)
/**
* @return Ebizmarts_MailChimp_Model_Ecommercesyncdata
*/
public function getMailchimpEcommerceSyncDataModel()
protected function getMailchimpEcommerceSyncDataModel()
{
return Mage::getModel('mailchimp/ecommercesyncdata');
}
Expand Down Expand Up @@ -4131,7 +4105,7 @@ protected function getCheckOutSession()
/**
* @return Mage_Sales_Model_Order
*/
public function getSalesOrderModel()
protected function getSalesOrderModel()
{
return Mage::getModel('sales/order');
}
Expand Down Expand Up @@ -4263,7 +4237,7 @@ public function ping($storeId)
/**
* @return Ebizmarts_MailChimp_Helper_File
*/
public function getFileHelper()
protected function getFileHelper()
{
return Mage::helper('mailchimp/file');
}
Expand Down
58 changes: 49 additions & 9 deletions app/code/community/Ebizmarts/MailChimp/Helper/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ protected function _migrateFrom115($initialTime)
*/
protected function _makeForCollectionItem($collection, $mailchimpStoreId, $initialTime, Closure $callback)
{
$helper = $this->getHelper();
$dateHelper = $this->getDateHelper();
$finished = false;

Expand All @@ -142,7 +141,7 @@ protected function _makeForCollectionItem($collection, $mailchimpStoreId, $initi

do {
$collection->setCurPage($currentPage);
$helper->_loadItemCollection($collection);
$this->_loadItemCollection($collection);

foreach ($collection as $collectionItem) {
$callback($collectionItem, $mailchimpStoreId);
Expand All @@ -166,6 +165,14 @@ protected function _makeForCollectionItem($collection, $mailchimpStoreId, $initi
return $finished;
}

/**
* @param $collection
*/
protected function _loadItemCollection($collection)
{
$collection->load();
}

protected function _migrateFrom115dropColumn($arrayMigrationConfigData)
{
$helper = $this->getHelper();
Expand Down Expand Up @@ -209,6 +216,14 @@ protected function _migrateFrom115dropColumn($arrayMigrationConfigData)
}
}

/**
* @return Ebizmarts_MailChimp_Model_Ecommercesyncdata
*/
protected function getMailchimpEcommerceSyncDataModel()
{
return Mage::getModel('mailchimp/ecommercesyncdata');
}

/**
* Migrate Customers from version 1.1.5 to the mailchimp_ecommerce_sync_data table.
*
Expand Down Expand Up @@ -256,7 +271,7 @@ function ($customer, $mailchimpStoreId) {
$syncModified = $customer->getMailchimpSyncModified();
}

$ecommerceSyncData = $helper->getMailchimpEcommerceSyncDataModel();
$ecommerceSyncData = $this->getMailchimpEcommerceSyncDataModel();
$ecommerceSyncData->saveEcommerceSyncData(
$customerId,
Ebizmarts_MailChimp_Model_Config::IS_CUSTOMER,
Expand Down Expand Up @@ -323,7 +338,7 @@ function ($product, $mailchimpStoreId) {
$syncModified = $product->getMailchimpSyncModified();
}

$ecommerceSyncData = $helper->getMailchimpEcommerceSyncDataModel();
$ecommerceSyncData = $this->getMailchimpEcommerceSyncDataModel();
$ecommerceSyncData->saveEcommerceSyncData(
$productId,
Ebizmarts_MailChimp_Model_Config::IS_PRODUCT,
Expand All @@ -340,6 +355,14 @@ function ($product, $mailchimpStoreId) {
}
}

/**
* @return Mage_Sales_Model_Order
*/
protected function getSalesOrderModel()
{
return Mage::getModel('sales/order');
}

/**
* Migrate Orders from version 1.1.5 to the mailchimp_ecommerce_sync_data table.
*
Expand Down Expand Up @@ -391,7 +414,7 @@ function ($order, $mailchimpStoreId) {
$syncModified = $order->getMailchimpSyncModified();
}

$ecommerceSyncData = $helper->getMailchimpEcommerceSyncDataModel();
$ecommerceSyncData = $this->getMailchimpEcommerceSyncDataModel();
$ecommerceSyncData->saveEcommerceSyncData(
$orderId,
Ebizmarts_MailChimp_Model_Config::IS_ORDER,
Expand Down Expand Up @@ -465,7 +488,7 @@ function ($quote, $mailchimpStoreId) {
$token = $quote->getMailchimpToken();
}

$ecommerceSyncData = $helper->getMailchimpEcommerceSyncDataModel();
$ecommerceSyncData = $this->getMailchimpEcommerceSyncDataModel();
$ecommerceSyncData->saveEcommerceSyncData(
$quoteId,
Ebizmarts_MailChimp_Model_Config::IS_QUOTE,
Expand Down Expand Up @@ -510,19 +533,36 @@ protected function delete115MigrationConfigData()
);
}

/**
* Modify is_syncing value if initial sync finished for all stores.
*
* @param $syncValue
*/
protected function _setIsSyncingIfFinishedInAllStores($syncValue)
{
$stores = $this->getMageApp()->getStores();

foreach ($stores as $storeId => $store) {
$ecommEnabled = $this->isEcomSyncDataEnabled($storeId);

if ($ecommEnabled) {
$this->setIsSyncingIfFinishedPerScope($syncValue, $storeId);
}
}
}

/**
* Migrate data from version 1.1.6.
*
* @param $initialTime
*/
protected function _migrateFrom116($initialTime)
{
$helper = $this->getHelper();
$helper->_setIsSyncingIfFinishedInAllStores(true);
$this->_setIsSyncingIfFinishedInAllStores(true);
$finished = $this->_migrateOrdersFrom116($initialTime);

if ($finished) {
$helper->_setIsSyncingIfFinishedInAllStores(false);
$this->_setIsSyncingIfFinishedInAllStores(false);
$arrayMigrationConfigData = array('115' => false, '116' => true, '1164' => false);
$this->handleDeleteMigrationConfigData($arrayMigrationConfigData);
}
Expand Down

0 comments on commit 63dd9fe

Please sign in to comment.