Skip to content

Commit

Permalink
Merge pull request #1192 from mailchimp/1189-ProtectedMethodsHelper
Browse files Browse the repository at this point in the history
Changed method visibility for functions used in other helpers/files
closes #1189
  • Loading branch information
giorello authored Oct 14, 2020
2 parents e89d174 + a55589a commit 30a3ba7
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 38 deletions.
28 changes: 1 addition & 27 deletions app/code/community/Ebizmarts/MailChimp/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -1972,32 +1972,6 @@ public function retrieveAndSaveMCJsUrlInConfig($scopeId, $scope = 'stores')
return $mcJsUrlSaved;
}

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

/**
* 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);
}
}
}

/**
* @return Ebizmarts_MailChimp_Helper_Webhook
*/
Expand Down Expand Up @@ -4139,7 +4113,7 @@ protected function getSalesOrderModel()
/**
* @return Ebizmarts_MailChimp_Helper_Date
*/
protected function getDateHelper()
public function getDateHelper()
{
return Mage::helper('mailchimp/date');
}
Expand Down
62 changes: 51 additions & 11 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 @@ -380,7 +403,7 @@ function ($order, $mailchimpStoreId) {
$orderId = $order->getEntityId();
$syncError = null;
$syncModified = null;
$orderObject = $helper->getSalesOrderModel()->load($orderId);
$orderObject = $this->getSalesOrderModel()->load($orderId);
$syncDelta = $orderObject->getMailchimpSyncDelta();

if ($order->getMailchimpSyncError()) {
Expand All @@ -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 @@ -450,7 +473,7 @@ function ($quote, $mailchimpStoreId) {
$syncError = null;
$syncDeleted = null;
$token = null;
$quoteObject = $helper->getSalesOrderModel()->load($quoteId);
$quoteObject = $this->getSalesOrderModel()->load($quoteId);
$syncDelta = $quoteObject->getMailchimpSyncDelta();

if ($quote->getMailchimpSyncError()) {
Expand All @@ -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 30a3ba7

Please sign in to comment.