diff --git a/app/code/community/Ebizmarts/MailChimp/Helper/Data.php b/app/code/community/Ebizmarts/MailChimp/Helper/Data.php index eac8baec2..a380470e3 100644 --- a/app/code/community/Ebizmarts/MailChimp/Helper/Data.php +++ b/app/code/community/Ebizmarts/MailChimp/Helper/Data.php @@ -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 */ @@ -4139,7 +4113,7 @@ protected function getSalesOrderModel() /** * @return Ebizmarts_MailChimp_Helper_Date */ - protected function getDateHelper() + public function getDateHelper() { return Mage::helper('mailchimp/date'); } diff --git a/app/code/community/Ebizmarts/MailChimp/Helper/Migration.php b/app/code/community/Ebizmarts/MailChimp/Helper/Migration.php index c3592fb1d..ace3e9cd4 100644 --- a/app/code/community/Ebizmarts/MailChimp/Helper/Migration.php +++ b/app/code/community/Ebizmarts/MailChimp/Helper/Migration.php @@ -127,7 +127,6 @@ protected function _migrateFrom115($initialTime) */ protected function _makeForCollectionItem($collection, $mailchimpStoreId, $initialTime, Closure $callback) { - $helper = $this->getHelper(); $dateHelper = $this->getDateHelper(); $finished = false; @@ -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); @@ -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(); @@ -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. * @@ -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, @@ -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, @@ -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. * @@ -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()) { @@ -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, @@ -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()) { @@ -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, @@ -510,6 +533,24 @@ 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. * @@ -517,12 +558,11 @@ protected function delete115MigrationConfigData() */ 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); }