Skip to content

Commit 30a3ba7

Browse files
authored
Merge pull request #1192 from mailchimp/1189-ProtectedMethodsHelper
Changed method visibility for functions used in other helpers/files closes #1189
2 parents e89d174 + a55589a commit 30a3ba7

File tree

2 files changed

+52
-38
lines changed

2 files changed

+52
-38
lines changed

app/code/community/Ebizmarts/MailChimp/Helper/Data.php

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1972,32 +1972,6 @@ public function retrieveAndSaveMCJsUrlInConfig($scopeId, $scope = 'stores')
19721972
return $mcJsUrlSaved;
19731973
}
19741974

1975-
/**
1976-
* @param $collection
1977-
*/
1978-
protected function _loadItemCollection($collection)
1979-
{
1980-
$collection->load();
1981-
}
1982-
1983-
/**
1984-
* Modify is_syncing value if initial sync finished for all stores.
1985-
*
1986-
* @param $syncValue
1987-
*/
1988-
protected function _setIsSyncingIfFinishedInAllStores($syncValue)
1989-
{
1990-
$stores = $this->getMageApp()->getStores();
1991-
1992-
foreach ($stores as $storeId => $store) {
1993-
$ecommEnabled = $this->isEcomSyncDataEnabled($storeId);
1994-
1995-
if ($ecommEnabled) {
1996-
$this->setIsSyncingIfFinishedPerScope($syncValue, $storeId);
1997-
}
1998-
}
1999-
}
2000-
20011975
/**
20021976
* @return Ebizmarts_MailChimp_Helper_Webhook
20031977
*/
@@ -4139,7 +4113,7 @@ protected function getSalesOrderModel()
41394113
/**
41404114
* @return Ebizmarts_MailChimp_Helper_Date
41414115
*/
4142-
protected function getDateHelper()
4116+
public function getDateHelper()
41434117
{
41444118
return Mage::helper('mailchimp/date');
41454119
}

app/code/community/Ebizmarts/MailChimp/Helper/Migration.php

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ protected function _migrateFrom115($initialTime)
127127
*/
128128
protected function _makeForCollectionItem($collection, $mailchimpStoreId, $initialTime, Closure $callback)
129129
{
130-
$helper = $this->getHelper();
131130
$dateHelper = $this->getDateHelper();
132131
$finished = false;
133132

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

143142
do {
144143
$collection->setCurPage($currentPage);
145-
$helper->_loadItemCollection($collection);
144+
$this->_loadItemCollection($collection);
146145

147146
foreach ($collection as $collectionItem) {
148147
$callback($collectionItem, $mailchimpStoreId);
@@ -166,6 +165,14 @@ protected function _makeForCollectionItem($collection, $mailchimpStoreId, $initi
166165
return $finished;
167166
}
168167

168+
/**
169+
* @param $collection
170+
*/
171+
protected function _loadItemCollection($collection)
172+
{
173+
$collection->load();
174+
}
175+
169176
protected function _migrateFrom115dropColumn($arrayMigrationConfigData)
170177
{
171178
$helper = $this->getHelper();
@@ -209,6 +216,14 @@ protected function _migrateFrom115dropColumn($arrayMigrationConfigData)
209216
}
210217
}
211218

219+
/**
220+
* @return Ebizmarts_MailChimp_Model_Ecommercesyncdata
221+
*/
222+
protected function getMailchimpEcommerceSyncDataModel()
223+
{
224+
return Mage::getModel('mailchimp/ecommercesyncdata');
225+
}
226+
212227
/**
213228
* Migrate Customers from version 1.1.5 to the mailchimp_ecommerce_sync_data table.
214229
*
@@ -256,7 +271,7 @@ function ($customer, $mailchimpStoreId) {
256271
$syncModified = $customer->getMailchimpSyncModified();
257272
}
258273

259-
$ecommerceSyncData = $helper->getMailchimpEcommerceSyncDataModel();
274+
$ecommerceSyncData = $this->getMailchimpEcommerceSyncDataModel();
260275
$ecommerceSyncData->saveEcommerceSyncData(
261276
$customerId,
262277
Ebizmarts_MailChimp_Model_Config::IS_CUSTOMER,
@@ -323,7 +338,7 @@ function ($product, $mailchimpStoreId) {
323338
$syncModified = $product->getMailchimpSyncModified();
324339
}
325340

326-
$ecommerceSyncData = $helper->getMailchimpEcommerceSyncDataModel();
341+
$ecommerceSyncData = $this->getMailchimpEcommerceSyncDataModel();
327342
$ecommerceSyncData->saveEcommerceSyncData(
328343
$productId,
329344
Ebizmarts_MailChimp_Model_Config::IS_PRODUCT,
@@ -340,6 +355,14 @@ function ($product, $mailchimpStoreId) {
340355
}
341356
}
342357

358+
/**
359+
* @return Mage_Sales_Model_Order
360+
*/
361+
protected function getSalesOrderModel()
362+
{
363+
return Mage::getModel('sales/order');
364+
}
365+
343366
/**
344367
* Migrate Orders from version 1.1.5 to the mailchimp_ecommerce_sync_data table.
345368
*
@@ -380,7 +403,7 @@ function ($order, $mailchimpStoreId) {
380403
$orderId = $order->getEntityId();
381404
$syncError = null;
382405
$syncModified = null;
383-
$orderObject = $helper->getSalesOrderModel()->load($orderId);
406+
$orderObject = $this->getSalesOrderModel()->load($orderId);
384407
$syncDelta = $orderObject->getMailchimpSyncDelta();
385408

386409
if ($order->getMailchimpSyncError()) {
@@ -391,7 +414,7 @@ function ($order, $mailchimpStoreId) {
391414
$syncModified = $order->getMailchimpSyncModified();
392415
}
393416

394-
$ecommerceSyncData = $helper->getMailchimpEcommerceSyncDataModel();
417+
$ecommerceSyncData = $this->getMailchimpEcommerceSyncDataModel();
395418
$ecommerceSyncData->saveEcommerceSyncData(
396419
$orderId,
397420
Ebizmarts_MailChimp_Model_Config::IS_ORDER,
@@ -450,7 +473,7 @@ function ($quote, $mailchimpStoreId) {
450473
$syncError = null;
451474
$syncDeleted = null;
452475
$token = null;
453-
$quoteObject = $helper->getSalesOrderModel()->load($quoteId);
476+
$quoteObject = $this->getSalesOrderModel()->load($quoteId);
454477
$syncDelta = $quoteObject->getMailchimpSyncDelta();
455478

456479
if ($quote->getMailchimpSyncError()) {
@@ -465,7 +488,7 @@ function ($quote, $mailchimpStoreId) {
465488
$token = $quote->getMailchimpToken();
466489
}
467490

468-
$ecommerceSyncData = $helper->getMailchimpEcommerceSyncDataModel();
491+
$ecommerceSyncData = $this->getMailchimpEcommerceSyncDataModel();
469492
$ecommerceSyncData->saveEcommerceSyncData(
470493
$quoteId,
471494
Ebizmarts_MailChimp_Model_Config::IS_QUOTE,
@@ -510,19 +533,36 @@ protected function delete115MigrationConfigData()
510533
);
511534
}
512535

536+
/**
537+
* Modify is_syncing value if initial sync finished for all stores.
538+
*
539+
* @param $syncValue
540+
*/
541+
protected function _setIsSyncingIfFinishedInAllStores($syncValue)
542+
{
543+
$stores = $this->getMageApp()->getStores();
544+
545+
foreach ($stores as $storeId => $store) {
546+
$ecommEnabled = $this->isEcomSyncDataEnabled($storeId);
547+
548+
if ($ecommEnabled) {
549+
$this->setIsSyncingIfFinishedPerScope($syncValue, $storeId);
550+
}
551+
}
552+
}
553+
513554
/**
514555
* Migrate data from version 1.1.6.
515556
*
516557
* @param $initialTime
517558
*/
518559
protected function _migrateFrom116($initialTime)
519560
{
520-
$helper = $this->getHelper();
521-
$helper->_setIsSyncingIfFinishedInAllStores(true);
561+
$this->_setIsSyncingIfFinishedInAllStores(true);
522562
$finished = $this->_migrateOrdersFrom116($initialTime);
523563

524564
if ($finished) {
525-
$helper->_setIsSyncingIfFinishedInAllStores(false);
565+
$this->_setIsSyncingIfFinishedInAllStores(false);
526566
$arrayMigrationConfigData = array('115' => false, '116' => true, '1164' => false);
527567
$this->handleDeleteMigrationConfigData($arrayMigrationConfigData);
528568
}

0 commit comments

Comments
 (0)