From 6f1bc0dba232207267a6fc37f73d30a9f5c2402c Mon Sep 17 00:00:00 2001 From: brian-ebizmarts Date: Mon, 15 Jul 2019 15:39:34 -0300 Subject: [PATCH 01/14] added calculateRowTotal function #999 --- .../Ebizmarts/MailChimp/Model/Api/Orders.php | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/app/code/community/Ebizmarts/MailChimp/Model/Api/Orders.php b/app/code/community/Ebizmarts/MailChimp/Model/Api/Orders.php index ccf9a745a..dbcd33bb6 100755 --- a/app/code/community/Ebizmarts/MailChimp/Model/Api/Orders.php +++ b/app/code/community/Ebizmarts/MailChimp/Model/Api/Orders.php @@ -48,6 +48,7 @@ public function createBatchJson($mailchimpStoreId, $magentoStoreId) // get all the orders modified $batchArray = array_merge($batchArray, $this->_getModifiedOrders($mailchimpStoreId, $magentoStoreId)); } + // get new orders $batchArray = array_merge($batchArray, $this->_getNewOrders($mailchimpStoreId, $magentoStoreId)); @@ -161,12 +162,26 @@ protected function _getNewOrders($mailchimpStoreId, $magentoStoreId) } /** - * Set all the data for each order to be sent - * - * @param $order - * @param $mailchimpStoreId - * @param $magentoStoreId - * @return string + * get order item total price + * @param $item + * @return mixed + */ + protected function calculateRowTotal($item) + { + $rowTotal = $item->getRowTotal() + $item->getTaxAmount() + + $item->getHiddenTaxAmount() + Mage::helper('weee')->getRowWeeeAmountAfterDiscount($item) + - $item->getDiscountAmount(); + + return $rowTotal; + } + + /** + * Set all the data for each order to be sent + * @param $order + * @param $mailchimpStoreId + * @param $magentoStoreId + * @return false|string + * @throws Mage_Core_Model_Store_Exception */ public function GeneratePOSTPayload($order, $mailchimpStoreId, $magentoStoreId) { @@ -260,7 +275,7 @@ public function GeneratePOSTPayload($order, $mailchimpStoreId, $magentoStoreId) "product_id" => $productId, "product_variant_id" => $variant, "quantity" => (int)$item->getQtyOrdered(), - "price" => $item->getPrice(), + "price" => $this->calculateRowTotal($item), "discount" => abs($item->getDiscountAmount()) ); @@ -689,6 +704,7 @@ public function getPromoData($order) } } } + return $promo; } From a3ba3656f87e45f2014631d2e44e2f3e6269acd0 Mon Sep 17 00:00:00 2001 From: brian-ebizmarts Date: Mon, 15 Jul 2019 16:07:25 -0300 Subject: [PATCH 02/14] orderTest modified #999 --- .../app/Ebizmarts/MailChimp/Model/Api/OrdersTest.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/dev/tests/mailchimp/tests/app/Ebizmarts/MailChimp/Model/Api/OrdersTest.php b/dev/tests/mailchimp/tests/app/Ebizmarts/MailChimp/Model/Api/OrdersTest.php index 4d665d12b..951ecce36 100755 --- a/dev/tests/mailchimp/tests/app/Ebizmarts/MailChimp/Model/Api/OrdersTest.php +++ b/dev/tests/mailchimp/tests/app/Ebizmarts/MailChimp/Model/Api/OrdersTest.php @@ -225,7 +225,8 @@ public function testGeneratePOSTPayload() 'getCountryModelNameFromShippingAddress', 'getResourceModelOrderCollection', 'shouldSendCampaignId', - 'getApiProduct' + 'getApiProduct', + 'calculateRowTotal' )) ->getMock(); @@ -259,7 +260,7 @@ public function testGeneratePOSTPayload() $itemOrderMock = $this->getMockBuilder(Mage_Sales_Model_Order_Item::class) ->disableOriginalConstructor() - ->setMethods(array('getProductId', 'getProductOptions', 'getQtyOrdered', 'getPrice', 'getDiscountAmount')) + ->setMethods(array('getProductId', 'getProductOptions', 'getQtyOrdered', 'getDiscountAmount')) ->getMock(); $productModelMock = $this->getMockBuilder(Mage_Catalog_Model_Product::class) @@ -436,6 +437,9 @@ public function testGeneratePOSTPayload() $ordersApiMock->expects($this->once()) ->method('getApiProduct') ->willReturn($apiProductMock); + $ordersApiMock->expects($this->once()) + ->method('calculateRowTotal') + ->with($itemOrderMock); $apiProductMock->expects($this->once()) ->method('isProductEnabled') @@ -454,9 +458,7 @@ public function testGeneratePOSTPayload() $itemOrderMock->expects($this->once()) ->method('getQtyOrdered') ->willReturn($qtyOrdered); - $itemOrderMock->expects($this->once()) - ->method('getPrice') - ->willReturn($price); + $itemOrderMock->expects($this->once()) ->method('getDiscountAmount') ->willReturn($discountAmount); From b8cc66e8457bc7a321e1a222925ea9e2ecdc6a19 Mon Sep 17 00:00:00 2001 From: brian-ebizmarts Date: Mon, 15 Jul 2019 16:12:06 -0300 Subject: [PATCH 03/14] coding standards #999 --- .../MailChimp/Model/Api/OrdersTest.php | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/dev/tests/mailchimp/tests/app/Ebizmarts/MailChimp/Model/Api/OrdersTest.php b/dev/tests/mailchimp/tests/app/Ebizmarts/MailChimp/Model/Api/OrdersTest.php index 951ecce36..bc36b1b60 100755 --- a/dev/tests/mailchimp/tests/app/Ebizmarts/MailChimp/Model/Api/OrdersTest.php +++ b/dev/tests/mailchimp/tests/app/Ebizmarts/MailChimp/Model/Api/OrdersTest.php @@ -204,13 +204,16 @@ public function testGeneratePOSTPayload() $apiProductMock = $this->getMockBuilder(Ebizmarts_MailChimp_Model_Api_Products::class) ->disableOriginalConstructor() - ->setMethods(array( + ->setMethods( + array( 'isProductEnabled' - )) + ) + ) ->getMock(); $ordersApiMock = $this->ordersApiMock - ->setMethods(array( + ->setMethods( + array( 'returnZeroIfNull', 'getPromoData', '_getMailChimpStatus', @@ -227,12 +230,14 @@ public function testGeneratePOSTPayload() 'shouldSendCampaignId', 'getApiProduct', 'calculateRowTotal' - )) + ) + ) ->getMock(); $orderMock = $this->getMockBuilder(Mage_Sales_Model_Order::class) ->disableOriginalConstructor() - ->setMethods(array( + ->setMethods( + array( 'getIncrementId', 'getMailchimpCampaignId', 'getMailchimpLandingPage', @@ -250,7 +255,8 @@ public function testGeneratePOSTPayload() 'getCustomerLastname', 'getBillingAddress', 'getShippingAddress' - )) + ) + ) ->getMock(); $itemsOrderCollection = $this->getMockBuilder(Mage_Sales_Model_Resource_Order_Item_Collection::class) @@ -280,7 +286,8 @@ public function testGeneratePOSTPayload() ->getMock(); $billingAddressMock = $this->getMockBuilder(Mage_Sales_Model_Order_Address::class) - ->setMethods(array( + ->setMethods( + array( 'getStreet', 'getCity', 'getRegion', @@ -289,11 +296,13 @@ public function testGeneratePOSTPayload() 'getCountry', 'getName', 'getCompany' - )) + ) + ) ->getMock(); $shippingAddressMock = $this->getMockBuilder(Mage_Sales_Model_Order_Address::class) - ->setMethods(array( + ->setMethods( + array( 'getStreet', 'getCity', 'getRegion', @@ -302,7 +311,8 @@ public function testGeneratePOSTPayload() 'getCountry', 'getName', 'getCompany' - )) + ) + ) ->getMock(); $orderCollectionMock = $this->getMockBuilder(Mage_Sales_Model_Resource_Order_Collection::class) @@ -626,10 +636,12 @@ public function testShouldSendCampaignId() $helperMock = $this->getMockBuilder(Ebizmarts_MailChimp_Helper_Data::class) ->disableOriginalConstructor() - ->setMethods(array( + ->setMethods( + array( 'getGeneralList', 'getApiKey', - 'getApi')) + 'getApi') + ) ->getMock(); $apiMock = $this->getMockBuilder(Ebizmarts_MailChimp::class) From ce6a21701fdb83267eb171cddc3d186fe60d5706 Mon Sep 17 00:00:00 2001 From: Roberto Sarmiento Date: Tue, 16 Jul 2019 15:09:29 -0300 Subject: [PATCH 04/14] Modifying isUseMagentoEmailsEnabled() return data type, in Data.php, in order to return an int. Modifying the logic in Observer.php (subscriberSaveAfter() method) in order to make possible the immediately sending of subscribers changes. Adding new constant: const SUBSCRIBE_CONFIRMATION = 'MailChimp_Confirmation'; for knowing when is required email confirmation. Modifying ObserverTest.php due to the changes made in Observer.php #996 --- .../Ebizmarts/MailChimp/Helper/Data.php | 2 +- .../Ebizmarts/MailChimp/Model/Observer.php | 19 +++- .../Ebizmarts/MailChimp/Model/Subscriber.php | 3 +- .../MailChimp/Model/ObserverTest.php | 99 +++++++++++++++++-- 4 files changed, 112 insertions(+), 11 deletions(-) diff --git a/app/code/community/Ebizmarts/MailChimp/Helper/Data.php b/app/code/community/Ebizmarts/MailChimp/Helper/Data.php index 349e5e2f1..6fd54eed7 100755 --- a/app/code/community/Ebizmarts/MailChimp/Helper/Data.php +++ b/app/code/community/Ebizmarts/MailChimp/Helper/Data.php @@ -315,7 +315,7 @@ public function isMailChimpEnabled($scopeId, $scope = null) */ public function isUseMagentoEmailsEnabled($scopeId) { - return $this->getConfigValueForScope(Ebizmarts_MailChimp_Model_Config::GENERAL_MAGENTO_MAIL, $scopeId); + return (int) $this->getConfigValueForScope(Ebizmarts_MailChimp_Model_Config::GENERAL_MAGENTO_MAIL, $scopeId); } /** diff --git a/app/code/community/Ebizmarts/MailChimp/Model/Observer.php b/app/code/community/Ebizmarts/MailChimp/Model/Observer.php index 7aef9259f..ac618c4c3 100755 --- a/app/code/community/Ebizmarts/MailChimp/Model/Observer.php +++ b/app/code/community/Ebizmarts/MailChimp/Model/Observer.php @@ -210,16 +210,19 @@ public function subscriberSaveAfter(Varien_Event_Observer $observer) $storeViewId = $this->getStoreViewIdBySubscriber($subscriber); $helper = $this->makeHelper(); $isEnabled = $helper->isSubscriptionEnabled($storeViewId); + $subscriberSource = $subscriber->getSubscriberSource(); - if ($isEnabled && $subscriber->getSubscriberSource() != Ebizmarts_MailChimp_Model_Subscriber::SUBSCRIBE_SOURCE) { + if ($isEnabled && $subscriberSource !== Ebizmarts_MailChimp_Model_Subscriber::SUBSCRIBE_SOURCE) { $params = $this->getRequest()->getParams(); $helper->saveInterestGroupData($params, $storeViewId, null, $subscriber); $this->createEmailCookie($subscriber); - if ($helper->isUseMagentoEmailsEnabled($storeViewId) != 1) { - $apiSubscriber = $this->makeApiSubscriber(); + $apiSubscriber = $this->makeApiSubscriber(); + if ($helper->isUseMagentoEmailsEnabled($storeViewId) !== 1 + && $this->isMagentoSubscription($subscriberSource) + || $this->isEmailConfirmationRequired($subscriberSource)) { if ($subscriber->getIsStatusChanged()) { $apiSubscriber->updateSubscriber($subscriber, true); } else { @@ -1167,4 +1170,14 @@ protected function getStoreViewIdBySubscriber($subscriber) return $storeViewId; } + protected function isEmailConfirmationRequired($subscriberSource) + { + return $subscriberSource === Ebizmarts_MailChimp_Model_Subscriber::SUBSCRIBE_CONFIRMATION; + } + + protected function isMagentoSubscription($subscriberSource) + { + return empty($subscriberSource); + } + } diff --git a/app/code/community/Ebizmarts/MailChimp/Model/Subscriber.php b/app/code/community/Ebizmarts/MailChimp/Model/Subscriber.php index 850bb4305..60242b555 100755 --- a/app/code/community/Ebizmarts/MailChimp/Model/Subscriber.php +++ b/app/code/community/Ebizmarts/MailChimp/Model/Subscriber.php @@ -9,6 +9,7 @@ class Ebizmarts_MailChimp_Model_Subscriber extends Mage_Newsletter_Model_Subscriber { const SUBSCRIBE_SOURCE = 'MailChimp'; + const SUBSCRIBE_CONFIRMATION = 'MailChimp_Confirmation'; public function sendUnsubscriptionEmail() { @@ -42,7 +43,7 @@ public function confirm($code) if ($this->getCode()==$code) { $this->setStatus(self::STATUS_SUBSCRIBED) ->setIsStatusChanged(true) - ->setSubscriberSource(Ebizmarts_MailChimp_Model_Subscriber::SUBSCRIBE_SOURCE) + ->setSubscriberSource(Ebizmarts_MailChimp_Model_Subscriber::SUBSCRIBE_CONFIRMATION) ->save(); return true; } diff --git a/dev/tests/mailchimp/tests/app/Ebizmarts/MailChimp/Model/ObserverTest.php b/dev/tests/mailchimp/tests/app/Ebizmarts/MailChimp/Model/ObserverTest.php index b21a85412..43f93784f 100755 --- a/dev/tests/mailchimp/tests/app/Ebizmarts/MailChimp/Model/ObserverTest.php +++ b/dev/tests/mailchimp/tests/app/Ebizmarts/MailChimp/Model/ObserverTest.php @@ -640,10 +640,11 @@ public function subscriberSaveBeforeDataProvider() ); } - public function testSubscriberSaveAfter() + public function testSubscriberSaveAfterUseMagentoEmail() { $storeViewId = 1; $params = array(); + $subscriberSource = null; $eventObserverMock = $this->getMockBuilder(Varien_Event_Observer::class) ->disableOriginalConstructor() @@ -652,7 +653,85 @@ public function testSubscriberSaveAfter() $observerMock = $this->getMockBuilder(Ebizmarts_MailChimp_Model_Observer::class) ->disableOriginalConstructor() - ->setMethods(array('makeHelper', 'getRequest', 'createEmailCookie', 'makeApiSubscriber', 'getStoreViewIdBySubscriber')) + ->setMethods( + array('makeHelper', 'getRequest', 'createEmailCookie', 'makeApiSubscriber', + 'getStoreViewIdBySubscriber', 'isEmailConfirmationRequired') + ) + ->getMock(); + + $helperMock = $this->getMockBuilder(Ebizmarts_MailChimp_Helper_Data::class) + ->disableOriginalConstructor() + ->setMethods(array('isSubscriptionEnabled', 'saveInterestGroupData', 'isUseMagentoEmailsEnabled')) + ->getMock(); + + $eventMock = $this->getMockBuilder(Varien_Event::class) + ->disableOriginalConstructor() + ->setMethods(array('getSubscriber')) + ->getMock(); + + $subscriberMock = $this->getMockBuilder(Mage_Newsletter_Model_Subscriber::class) + ->disableOriginalConstructor() + ->setMethods(array('getSubscriberSource')) + ->getMock(); + + $requestMock = $this->getMockBuilder(Mage_Core_Controller_Request_Http::class) + ->disableOriginalConstructor() + ->setMethods(array('getParams')) + ->getMock(); + + $apiSubscriberMock = $this->getMockBuilder(Ebizmarts_MailChimp_Model_Api_Subscribers::class) + ->disableOriginalConstructor() + ->getMock(); + + $eventObserverMock->expects($this->once())->method('getEvent')->willReturn($eventMock); + + $eventMock->expects($this->once())->method('getSubscriber')->willReturn($subscriberMock); + + $observerMock->expects($this->once())->method('getStoreViewIdBySubscriber') + ->with($subscriberMock)->willReturn($storeViewId); + + $observerMock->expects($this->once())->method('makeHelper')->willReturn($helperMock); + + $subscriberMock->expects($this->once())->method('getSubscriberSource')->willReturn($subscriberSource); + + $helperMock->expects($this->once())->method('isSubscriptionEnabled')->with($storeViewId)->willReturn(true); + + $observerMock->expects($this->once())->method('getRequest')->willReturn($requestMock); + + $requestMock->expects($this->once())->method('getParams')->willReturn($params); + + $helperMock->expects($this->once())->method('saveInterestGroupData') + ->with($params, $storeViewId, null, $subscriberMock); + + $observerMock->expects($this->once())->method('isEmailConfirmationRequired') + ->with($subscriberSource)->willReturn(false); + + $observerMock->expects($this->once())->method('createEmailCookie')->with($subscriberMock); + + $helperMock->expects($this->once())->method('isUseMagentoEmailsEnabled')->with($storeViewId)->willReturn(1); + + $observerMock->expects($this->once())->method('makeApiSubscriber')->willReturn($apiSubscriberMock); + + $observerMock->subscriberSaveAfter($eventObserverMock); + } + + public function testSubscriberSaveAfterEmailConfirmation() + { + $storeViewId = 1; + $params = array(); + $subscriberSource = Ebizmarts_MailChimp_Model_Subscriber::SUBSCRIBE_CONFIRMATION; + + $eventObserverMock = $this->getMockBuilder(Varien_Event_Observer::class) + ->disableOriginalConstructor() + ->setMethods(array('getEvent')) + ->getMock(); + + $observerMock = $this->getMockBuilder(Ebizmarts_MailChimp_Model_Observer::class) + ->disableOriginalConstructor() + ->setMethods( + array('makeHelper', 'getRequest', 'createEmailCookie', 'makeApiSubscriber', + 'getStoreViewIdBySubscriber', 'isMagentoSubscription', 'isEmailConfirmationRequired') + ) ->getMock(); $helperMock = $this->getMockBuilder(Ebizmarts_MailChimp_Helper_Data::class) @@ -684,11 +763,12 @@ public function testSubscriberSaveAfter() $eventMock->expects($this->once())->method('getSubscriber')->willReturn($subscriberMock); - $observerMock->expects($this->once())->method('getStoreViewIdBySubscriber')->with($subscriberMock)->willReturn($storeViewId); + $observerMock->expects($this->once())->method('getStoreViewIdBySubscriber') + ->with($subscriberMock)->willReturn($storeViewId); $observerMock->expects($this->once())->method('makeHelper')->willReturn($helperMock); - $subscriberMock->expects($this->once())->method('getSubscriberSource')->willReturn(null); + $subscriberMock->expects($this->once())->method('getSubscriberSource')->willReturn($subscriberSource); $helperMock->expects($this->once())->method('isSubscriptionEnabled')->with($storeViewId)->willReturn(true); @@ -696,11 +776,18 @@ public function testSubscriberSaveAfter() $requestMock->expects($this->once())->method('getParams')->willReturn($params); - $helperMock->expects($this->once())->method('saveInterestGroupData')->with($params, $storeViewId, null, $subscriberMock); + $helperMock->expects($this->once())->method('saveInterestGroupData') + ->with($params, $storeViewId, null, $subscriberMock); + + $observerMock->expects($this->once())->method('isMagentoSubscription') + ->with($subscriberSource)->willReturn(false); + + $observerMock->expects($this->once())->method('isEmailConfirmationRequired') + ->with($subscriberSource)->willReturn(true); $observerMock->expects($this->once())->method('createEmailCookie')->with($subscriberMock); - $helperMock->expects($this->once())->method('isUseMagentoEmailsEnabled')->with($storeViewId)->willReturn(false); + $helperMock->expects($this->once())->method('isUseMagentoEmailsEnabled')->with($storeViewId)->willReturn(0); $subscriberMock->expects($this->once())->method('getIsStatusChanged')->willReturn(true); From fd52df99812af9467dacea60ec2fe35f77b6c0b1 Mon Sep 17 00:00:00 2001 From: Roberto Sarmiento Date: Tue, 16 Jul 2019 16:09:54 -0300 Subject: [PATCH 05/14] Extracting logic: $subscriberSource !== Ebizmarts_MailChimp_Model_Subscriber::SUBSCRIBE_SOURCE to new method named isMailchimpSave() Modifying ObserverTest.php due to the changes made in Observer.php #996 --- .../community/Ebizmarts/MailChimp/Model/Observer.php | 11 ++++++++++- dev/tests/mailchimp/autoload.php | 2 +- .../app/Ebizmarts/MailChimp/Model/ObserverTest.php | 9 +++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/app/code/community/Ebizmarts/MailChimp/Model/Observer.php b/app/code/community/Ebizmarts/MailChimp/Model/Observer.php index ac618c4c3..88a670555 100755 --- a/app/code/community/Ebizmarts/MailChimp/Model/Observer.php +++ b/app/code/community/Ebizmarts/MailChimp/Model/Observer.php @@ -212,7 +212,7 @@ public function subscriberSaveAfter(Varien_Event_Observer $observer) $isEnabled = $helper->isSubscriptionEnabled($storeViewId); $subscriberSource = $subscriber->getSubscriberSource(); - if ($isEnabled && $subscriberSource !== Ebizmarts_MailChimp_Model_Subscriber::SUBSCRIBE_SOURCE) { + if ($isEnabled && !$this->isMailchimpSave($subscriberSource)) { $params = $this->getRequest()->getParams(); $helper->saveInterestGroupData($params, $storeViewId, null, $subscriber); @@ -1180,4 +1180,13 @@ protected function isMagentoSubscription($subscriberSource) return empty($subscriberSource); } + /** + * @param $subscriberSource + * @return bool + */ + protected function isMailchimpSave($subscriberSource) + { + return $subscriberSource === Ebizmarts_MailChimp_Model_Subscriber::SUBSCRIBE_SOURCE; + } + } diff --git a/dev/tests/mailchimp/autoload.php b/dev/tests/mailchimp/autoload.php index e42485cd1..20f32bf86 100644 --- a/dev/tests/mailchimp/autoload.php +++ b/dev/tests/mailchimp/autoload.php @@ -10,7 +10,7 @@ //Set custom memory limit ini_set('memory_limit', '512M'); //Include Magento libraries -require_once(MAGENTO_ROOT .'/app/Mage.php'); +require_once(MAGENTO_ROOT .'../../../app/Mage.php'); //Start the Magento application Mage::app('default'); //Avoid issues "Headers already send" diff --git a/dev/tests/mailchimp/tests/app/Ebizmarts/MailChimp/Model/ObserverTest.php b/dev/tests/mailchimp/tests/app/Ebizmarts/MailChimp/Model/ObserverTest.php index 43f93784f..ea9ff7342 100755 --- a/dev/tests/mailchimp/tests/app/Ebizmarts/MailChimp/Model/ObserverTest.php +++ b/dev/tests/mailchimp/tests/app/Ebizmarts/MailChimp/Model/ObserverTest.php @@ -655,7 +655,7 @@ public function testSubscriberSaveAfterUseMagentoEmail() ->disableOriginalConstructor() ->setMethods( array('makeHelper', 'getRequest', 'createEmailCookie', 'makeApiSubscriber', - 'getStoreViewIdBySubscriber', 'isEmailConfirmationRequired') + 'getStoreViewIdBySubscriber', 'isEmailConfirmationRequired', 'isMailchimpSave') ) ->getMock(); @@ -694,6 +694,8 @@ public function testSubscriberSaveAfterUseMagentoEmail() $subscriberMock->expects($this->once())->method('getSubscriberSource')->willReturn($subscriberSource); + $observerMock->expects($this->once())->method('isMailchimpSave')->with($subscriberSource)->willReturn(false); + $helperMock->expects($this->once())->method('isSubscriptionEnabled')->with($storeViewId)->willReturn(true); $observerMock->expects($this->once())->method('getRequest')->willReturn($requestMock); @@ -730,7 +732,8 @@ public function testSubscriberSaveAfterEmailConfirmation() ->disableOriginalConstructor() ->setMethods( array('makeHelper', 'getRequest', 'createEmailCookie', 'makeApiSubscriber', - 'getStoreViewIdBySubscriber', 'isMagentoSubscription', 'isEmailConfirmationRequired') + 'getStoreViewIdBySubscriber', 'isMagentoSubscription', 'isEmailConfirmationRequired', + 'isMailchimpSave') ) ->getMock(); @@ -770,6 +773,8 @@ public function testSubscriberSaveAfterEmailConfirmation() $subscriberMock->expects($this->once())->method('getSubscriberSource')->willReturn($subscriberSource); + $observerMock->expects($this->once())->method('isMailchimpSave')->with($subscriberSource)->willReturn(false); + $helperMock->expects($this->once())->method('isSubscriptionEnabled')->with($storeViewId)->willReturn(true); $observerMock->expects($this->once())->method('getRequest')->willReturn($requestMock); From f5bd31eb329477cea660014612455c952f006a17 Mon Sep 17 00:00:00 2001 From: Roberto Sarmiento Date: Tue, 16 Jul 2019 16:21:39 -0300 Subject: [PATCH 06/14] Solving error related to earlier commit with wrong path in autoload.php #996 --- dev/tests/mailchimp/autoload.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/mailchimp/autoload.php b/dev/tests/mailchimp/autoload.php index 20f32bf86..e42485cd1 100644 --- a/dev/tests/mailchimp/autoload.php +++ b/dev/tests/mailchimp/autoload.php @@ -10,7 +10,7 @@ //Set custom memory limit ini_set('memory_limit', '512M'); //Include Magento libraries -require_once(MAGENTO_ROOT .'../../../app/Mage.php'); +require_once(MAGENTO_ROOT .'/app/Mage.php'); //Start the Magento application Mage::app('default'); //Avoid issues "Headers already send" From dba1130c6e76fe6f7ff64fc4d02e5a8468e0a362 Mon Sep 17 00:00:00 2001 From: Roberto Sarmiento Date: Tue, 16 Jul 2019 17:13:23 -0300 Subject: [PATCH 07/14] Renaming constant: Ebizmarts_MailChimp_Model_Subscriber::SUBSCRIBE_SOURCE to Ebizmarts_MailChimp_Model_Subscriber::MAILCHIMP_SUBSCRIBE #996 --- app/code/community/Ebizmarts/MailChimp/Helper/Data.php | 4 ++-- .../community/Ebizmarts/MailChimp/Model/Api/Subscribers.php | 4 ++-- app/code/community/Ebizmarts/MailChimp/Model/Observer.php | 4 ++-- .../community/Ebizmarts/MailChimp/Model/ProcessWebhook.php | 4 ++-- app/code/community/Ebizmarts/MailChimp/Model/Subscriber.php | 2 +- .../app/Ebizmarts/MailChimp/Model/ProcessWebhookTest.php | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/code/community/Ebizmarts/MailChimp/Helper/Data.php b/app/code/community/Ebizmarts/MailChimp/Helper/Data.php index 6fd54eed7..c693a372b 100755 --- a/app/code/community/Ebizmarts/MailChimp/Helper/Data.php +++ b/app/code/community/Ebizmarts/MailChimp/Helper/Data.php @@ -2825,7 +2825,7 @@ public function updateSubscriberSyndData($itemId, $syncDelta = null, $syncError if ($syncDeleted) { $subscriber->setData("mailchimp_sync_deleted", $syncDeleted); } - $subscriber->setSubscriberSource(Ebizmarts_MailChimp_Model_Subscriber::SUBSCRIBE_SOURCE); + $subscriber->setSubscriberSource(Ebizmarts_MailChimp_Model_Subscriber::MAILCHIMP_SUBSCRIBE); $subscriber->save(); } } @@ -3510,7 +3510,7 @@ public function unsubscribeMember($subscriber) protected function setMemberGeneralData($subscriber) { $subscriber->setImportMode(true); - $subscriber->setSubscriberSource(Ebizmarts_MailChimp_Model_Subscriber::SUBSCRIBE_SOURCE); + $subscriber->setSubscriberSource(Ebizmarts_MailChimp_Model_Subscriber::MAILCHIMP_SUBSCRIBE); $subscriber->setIsStatusChanged(true); $subscriber->save(); } diff --git a/app/code/community/Ebizmarts/MailChimp/Model/Api/Subscribers.php b/app/code/community/Ebizmarts/MailChimp/Model/Api/Subscribers.php index cc33521cd..21f0c3ed3 100644 --- a/app/code/community/Ebizmarts/MailChimp/Model/Api/Subscribers.php +++ b/app/code/community/Ebizmarts/MailChimp/Model/Api/Subscribers.php @@ -117,7 +117,7 @@ public function createBatchJson($listId, $storeId, $limit) $subscriber->setData("mailchimp_sync_delta", Varien_Date::now()); $subscriber->setData("mailchimp_sync_error", ""); $subscriber->setData("mailchimp_sync_modified", 0); - $subscriber->setSubscriberSource(Ebizmarts_MailChimp_Model_Subscriber::SUBSCRIBE_SOURCE); + $subscriber->setSubscriberSource(Ebizmarts_MailChimp_Model_Subscriber::MAILCHIMP_SUBSCRIBE); $subscriber->save(); } @@ -288,7 +288,7 @@ public function updateSubscriber($subscriber, $updateStatus = false) } if ($saveSubscriber) { - $subscriber->setSubscriberSource(Ebizmarts_MailChimp_Model_Subscriber::SUBSCRIBE_SOURCE); + $subscriber->setSubscriberSource(Ebizmarts_MailChimp_Model_Subscriber::MAILCHIMP_SUBSCRIBE); $subscriber->save(); } } diff --git a/app/code/community/Ebizmarts/MailChimp/Model/Observer.php b/app/code/community/Ebizmarts/MailChimp/Model/Observer.php index 88a670555..4120afae7 100755 --- a/app/code/community/Ebizmarts/MailChimp/Model/Observer.php +++ b/app/code/community/Ebizmarts/MailChimp/Model/Observer.php @@ -183,7 +183,7 @@ public function subscriberSaveBefore(Varien_Event_Observer $observer) $helper = $this->makeHelper(); $isEnabled = $helper->isSubscriptionEnabled($storeId); - if ($isEnabled && $subscriber->getSubscriberSource() != Ebizmarts_MailChimp_Model_Subscriber::SUBSCRIBE_SOURCE) { + if ($isEnabled && $subscriber->getSubscriberSource() != Ebizmarts_MailChimp_Model_Subscriber::MAILCHIMP_SUBSCRIBE) { $statusChanged = $subscriber->getIsStatusChanged(); //Override Magento status to always send double opt-in confirmation. @@ -1186,7 +1186,7 @@ protected function isMagentoSubscription($subscriberSource) */ protected function isMailchimpSave($subscriberSource) { - return $subscriberSource === Ebizmarts_MailChimp_Model_Subscriber::SUBSCRIBE_SOURCE; + return $subscriberSource === Ebizmarts_MailChimp_Model_Subscriber::MAILCHIMP_SUBSCRIBE; } } diff --git a/app/code/community/Ebizmarts/MailChimp/Model/ProcessWebhook.php b/app/code/community/Ebizmarts/MailChimp/Model/ProcessWebhook.php index ecd0366c1..a6adc577f 100755 --- a/app/code/community/Ebizmarts/MailChimp/Model/ProcessWebhook.php +++ b/app/code/community/Ebizmarts/MailChimp/Model/ProcessWebhook.php @@ -102,7 +102,7 @@ protected function _updateEmail(array $data) if (!$newSubscriber->getId()) { if ($oldSubscriber->getId()) { $oldSubscriber->setSubscriberEmail($new); - $oldSubscriber->setSubscriberSource(Ebizmarts_MailChimp_Model_Subscriber::SUBSCRIBE_SOURCE); + $oldSubscriber->setSubscriberSource(Ebizmarts_MailChimp_Model_Subscriber::MAILCHIMP_SUBSCRIBE); $oldSubscriber->save(); } else { $helper->subscribeMember($newSubscriber); @@ -236,7 +236,7 @@ public function _profile(array $data) $saveRequired = true; } if ($saveRequired) { - $subscriber->setSubscriberSource(Ebizmarts_MailChimp_Model_Subscriber::SUBSCRIBE_SOURCE); + $subscriber->setSubscriberSource(Ebizmarts_MailChimp_Model_Subscriber::MAILCHIMP_SUBSCRIBE); $subscriber->save(); } } else { diff --git a/app/code/community/Ebizmarts/MailChimp/Model/Subscriber.php b/app/code/community/Ebizmarts/MailChimp/Model/Subscriber.php index 60242b555..26c69186b 100755 --- a/app/code/community/Ebizmarts/MailChimp/Model/Subscriber.php +++ b/app/code/community/Ebizmarts/MailChimp/Model/Subscriber.php @@ -8,7 +8,7 @@ */ class Ebizmarts_MailChimp_Model_Subscriber extends Mage_Newsletter_Model_Subscriber { - const SUBSCRIBE_SOURCE = 'MailChimp'; + const MAILCHIMP_SUBSCRIBE = 'MailChimp'; const SUBSCRIBE_CONFIRMATION = 'MailChimp_Confirmation'; public function sendUnsubscriptionEmail() diff --git a/dev/tests/mailchimp/tests/app/Ebizmarts/MailChimp/Model/ProcessWebhookTest.php b/dev/tests/mailchimp/tests/app/Ebizmarts/MailChimp/Model/ProcessWebhookTest.php index 44401f258..5e0c993b1 100755 --- a/dev/tests/mailchimp/tests/app/Ebizmarts/MailChimp/Model/ProcessWebhookTest.php +++ b/dev/tests/mailchimp/tests/app/Ebizmarts/MailChimp/Model/ProcessWebhookTest.php @@ -48,7 +48,7 @@ public function testWebhookProfileSubscriberExists() $email = $data['email'] = 'brian+enterprisex1@ebizmarts.com'; $fname = $data['merges']['FNAME'] = 'Enterprise1'; $lname = $data['merges']['LNAME'] = 'enterprise11'; - $subscribeSource = Ebizmarts_MailChimp_Model_Subscriber::SUBSCRIBE_SOURCE; + $subscribeSource = Ebizmarts_MailChimp_Model_Subscriber::MAILCHIMP_SUBSCRIBE; $processWebhookMock = $this->getMockBuilder(Ebizmarts_MailChimp_Model_ProcessWebhook::class) ->disableOriginalConstructor() From 4d4ad854ba838f082e45b55c679fec3aad201dc8 Mon Sep 17 00:00:00 2001 From: brian-ebizmarts <46751037+brian-ebizmarts@users.noreply.github.com> Date: Tue, 16 Jul 2019 17:28:16 -0300 Subject: [PATCH 08/14] Revert "Incoherence in order item price #999" --- .../Ebizmarts/MailChimp/Model/Api/Orders.php | 30 +++--------- .../MailChimp/Model/Api/OrdersTest.php | 48 +++++++------------ 2 files changed, 24 insertions(+), 54 deletions(-) diff --git a/app/code/community/Ebizmarts/MailChimp/Model/Api/Orders.php b/app/code/community/Ebizmarts/MailChimp/Model/Api/Orders.php index dbcd33bb6..ccf9a745a 100755 --- a/app/code/community/Ebizmarts/MailChimp/Model/Api/Orders.php +++ b/app/code/community/Ebizmarts/MailChimp/Model/Api/Orders.php @@ -48,7 +48,6 @@ public function createBatchJson($mailchimpStoreId, $magentoStoreId) // get all the orders modified $batchArray = array_merge($batchArray, $this->_getModifiedOrders($mailchimpStoreId, $magentoStoreId)); } - // get new orders $batchArray = array_merge($batchArray, $this->_getNewOrders($mailchimpStoreId, $magentoStoreId)); @@ -162,26 +161,12 @@ protected function _getNewOrders($mailchimpStoreId, $magentoStoreId) } /** - * get order item total price - * @param $item - * @return mixed - */ - protected function calculateRowTotal($item) - { - $rowTotal = $item->getRowTotal() + $item->getTaxAmount() - + $item->getHiddenTaxAmount() + Mage::helper('weee')->getRowWeeeAmountAfterDiscount($item) - - $item->getDiscountAmount(); - - return $rowTotal; - } - - /** - * Set all the data for each order to be sent - * @param $order - * @param $mailchimpStoreId - * @param $magentoStoreId - * @return false|string - * @throws Mage_Core_Model_Store_Exception + * Set all the data for each order to be sent + * + * @param $order + * @param $mailchimpStoreId + * @param $magentoStoreId + * @return string */ public function GeneratePOSTPayload($order, $mailchimpStoreId, $magentoStoreId) { @@ -275,7 +260,7 @@ public function GeneratePOSTPayload($order, $mailchimpStoreId, $magentoStoreId) "product_id" => $productId, "product_variant_id" => $variant, "quantity" => (int)$item->getQtyOrdered(), - "price" => $this->calculateRowTotal($item), + "price" => $item->getPrice(), "discount" => abs($item->getDiscountAmount()) ); @@ -704,7 +689,6 @@ public function getPromoData($order) } } } - return $promo; } diff --git a/dev/tests/mailchimp/tests/app/Ebizmarts/MailChimp/Model/Api/OrdersTest.php b/dev/tests/mailchimp/tests/app/Ebizmarts/MailChimp/Model/Api/OrdersTest.php index bc36b1b60..4d665d12b 100755 --- a/dev/tests/mailchimp/tests/app/Ebizmarts/MailChimp/Model/Api/OrdersTest.php +++ b/dev/tests/mailchimp/tests/app/Ebizmarts/MailChimp/Model/Api/OrdersTest.php @@ -204,16 +204,13 @@ public function testGeneratePOSTPayload() $apiProductMock = $this->getMockBuilder(Ebizmarts_MailChimp_Model_Api_Products::class) ->disableOriginalConstructor() - ->setMethods( - array( + ->setMethods(array( 'isProductEnabled' - ) - ) + )) ->getMock(); $ordersApiMock = $this->ordersApiMock - ->setMethods( - array( + ->setMethods(array( 'returnZeroIfNull', 'getPromoData', '_getMailChimpStatus', @@ -228,16 +225,13 @@ public function testGeneratePOSTPayload() 'getCountryModelNameFromShippingAddress', 'getResourceModelOrderCollection', 'shouldSendCampaignId', - 'getApiProduct', - 'calculateRowTotal' - ) - ) + 'getApiProduct' + )) ->getMock(); $orderMock = $this->getMockBuilder(Mage_Sales_Model_Order::class) ->disableOriginalConstructor() - ->setMethods( - array( + ->setMethods(array( 'getIncrementId', 'getMailchimpCampaignId', 'getMailchimpLandingPage', @@ -255,8 +249,7 @@ public function testGeneratePOSTPayload() 'getCustomerLastname', 'getBillingAddress', 'getShippingAddress' - ) - ) + )) ->getMock(); $itemsOrderCollection = $this->getMockBuilder(Mage_Sales_Model_Resource_Order_Item_Collection::class) @@ -266,7 +259,7 @@ public function testGeneratePOSTPayload() $itemOrderMock = $this->getMockBuilder(Mage_Sales_Model_Order_Item::class) ->disableOriginalConstructor() - ->setMethods(array('getProductId', 'getProductOptions', 'getQtyOrdered', 'getDiscountAmount')) + ->setMethods(array('getProductId', 'getProductOptions', 'getQtyOrdered', 'getPrice', 'getDiscountAmount')) ->getMock(); $productModelMock = $this->getMockBuilder(Mage_Catalog_Model_Product::class) @@ -286,8 +279,7 @@ public function testGeneratePOSTPayload() ->getMock(); $billingAddressMock = $this->getMockBuilder(Mage_Sales_Model_Order_Address::class) - ->setMethods( - array( + ->setMethods(array( 'getStreet', 'getCity', 'getRegion', @@ -296,13 +288,11 @@ public function testGeneratePOSTPayload() 'getCountry', 'getName', 'getCompany' - ) - ) + )) ->getMock(); $shippingAddressMock = $this->getMockBuilder(Mage_Sales_Model_Order_Address::class) - ->setMethods( - array( + ->setMethods(array( 'getStreet', 'getCity', 'getRegion', @@ -311,8 +301,7 @@ public function testGeneratePOSTPayload() 'getCountry', 'getName', 'getCompany' - ) - ) + )) ->getMock(); $orderCollectionMock = $this->getMockBuilder(Mage_Sales_Model_Resource_Order_Collection::class) @@ -447,9 +436,6 @@ public function testGeneratePOSTPayload() $ordersApiMock->expects($this->once()) ->method('getApiProduct') ->willReturn($apiProductMock); - $ordersApiMock->expects($this->once()) - ->method('calculateRowTotal') - ->with($itemOrderMock); $apiProductMock->expects($this->once()) ->method('isProductEnabled') @@ -468,7 +454,9 @@ public function testGeneratePOSTPayload() $itemOrderMock->expects($this->once()) ->method('getQtyOrdered') ->willReturn($qtyOrdered); - + $itemOrderMock->expects($this->once()) + ->method('getPrice') + ->willReturn($price); $itemOrderMock->expects($this->once()) ->method('getDiscountAmount') ->willReturn($discountAmount); @@ -636,12 +624,10 @@ public function testShouldSendCampaignId() $helperMock = $this->getMockBuilder(Ebizmarts_MailChimp_Helper_Data::class) ->disableOriginalConstructor() - ->setMethods( - array( + ->setMethods(array( 'getGeneralList', 'getApiKey', - 'getApi') - ) + 'getApi')) ->getMock(); $apiMock = $this->getMockBuilder(Ebizmarts_MailChimp::class) From d02a209370b7c4055d0ef6ea19925d5131cb266b Mon Sep 17 00:00:00 2001 From: Roberto Sarmiento Date: Wed, 17 Jul 2019 10:54:41 -0300 Subject: [PATCH 09/14] Reusing previous implemented method: isMailchimpSave(). Replacing: $subscriber->getSubscriberSource() != Ebizmarts_MailChimp_Model_Subscriber::MAILCHIMP_SUBSCRIBE by: isMailchimpSave($subscriber->getSubscriberSource()) Changing ObserverTest.php due to changes made to Observer.php #996 --- .../Ebizmarts/MailChimp/Model/Observer.php | 6 ++++-- .../MailChimp/Model/ObserverTest.php | 19 ++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/code/community/Ebizmarts/MailChimp/Model/Observer.php b/app/code/community/Ebizmarts/MailChimp/Model/Observer.php index 4120afae7..9e5d83cd0 100755 --- a/app/code/community/Ebizmarts/MailChimp/Model/Observer.php +++ b/app/code/community/Ebizmarts/MailChimp/Model/Observer.php @@ -179,15 +179,17 @@ protected function isListXorStoreInherited($configData) public function subscriberSaveBefore(Varien_Event_Observer $observer) { $subscriber = $observer->getEvent()->getSubscriber(); + $subscriberSource = $subscriber->getSubscriberSource(); $storeId = $subscriber->getStoreId(); $helper = $this->makeHelper(); $isEnabled = $helper->isSubscriptionEnabled($storeId); - if ($isEnabled && $subscriber->getSubscriberSource() != Ebizmarts_MailChimp_Model_Subscriber::MAILCHIMP_SUBSCRIBE) { + if ($isEnabled && !$this->isMailchimpSave($subscriberSource)) { $statusChanged = $subscriber->getIsStatusChanged(); //Override Magento status to always send double opt-in confirmation. - if ($statusChanged && $subscriber->getStatus() == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED && $helper->isSubscriptionConfirmationEnabled($storeId) && !$helper->isUseMagentoEmailsEnabled($storeId)) { + if ($statusChanged && $subscriber->getStatus() == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED && + $helper->isSubscriptionConfirmationEnabled($storeId) && !$helper->isUseMagentoEmailsEnabled($storeId)) { $subscriber->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE); $this->addSuccessIfRequired($helper); } diff --git a/dev/tests/mailchimp/tests/app/Ebizmarts/MailChimp/Model/ObserverTest.php b/dev/tests/mailchimp/tests/app/Ebizmarts/MailChimp/Model/ObserverTest.php index ea9ff7342..2e97575f2 100755 --- a/dev/tests/mailchimp/tests/app/Ebizmarts/MailChimp/Model/ObserverTest.php +++ b/dev/tests/mailchimp/tests/app/Ebizmarts/MailChimp/Model/ObserverTest.php @@ -573,6 +573,7 @@ public function testSubscriberSaveBefore($data) { $getStoreId = $data['getStoreId']; $storeId = 1; + $subscriberSource = null; $eventObserverMock = $this->getMockBuilder(Varien_Event_Observer::class) ->disableOriginalConstructor() @@ -581,7 +582,7 @@ public function testSubscriberSaveBefore($data) $observerMock = $this->getMockBuilder(Ebizmarts_MailChimp_Model_Observer::class) ->disableOriginalConstructor() - ->setMethods(array('makeHelper', 'addSuccessIfRequired')) + ->setMethods(array('makeHelper', 'addSuccessIfRequired', 'isMailchimpSave')) ->getMock(); $helperMock = $this->getMockBuilder(Ebizmarts_MailChimp_Helper_Data::class) @@ -606,29 +607,33 @@ public function testSubscriberSaveBefore($data) $eventMock->expects($this->once())->method('getSubscriber')->willReturn($subscriberMock); + $subscriberMock->expects($this->once())->method('getSubscriberSource')->willReturn($subscriberSource); + $subscriberMock->expects($this->once())->method('getStoreId')->willReturn($storeId); $observerMock->expects($this->once())->method('makeHelper')->willReturn($helperMock); $helperMock->expects($this->once())->method('isSubscriptionEnabled')->with($storeId)->willReturn(true); - $subscriberMock->expects($this->once())->method('getStatus')->willReturn(Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED); + $subscriberMock->expects($this->once())->method('getStatus') + ->willReturn(Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED); + + $observerMock->expects($this->once())->method('isMailchimpSave')->with($subscriberSource)->willReturn(false); $subscriberMock->expects($this->once())->method('getIsStatusChanged')->willReturn(true); - $helperMock->expects($this->once())->method('isSubscriptionConfirmationEnabled')->with($storeId)->willReturn(true); + $helperMock->expects($this->once())->method('isSubscriptionConfirmationEnabled')->with($storeId) + ->willReturn(true); $helperMock->expects($this->once())->method('isUseMagentoEmailsEnabled')->with($storeId)->willReturn(false); - $subscriberMock->expects($this->once())->method('setStatus')->with(Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE); + $subscriberMock->expects($this->once())->method('setStatus') + ->with(Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE); $observerMock->expects($this->once())->method('addSuccessIfRequired')->with($helperMock); - $subscriberMock->expects($this->once())->method('getSubscriberSource')->willReturn(null); - $subscriberMock->expects($this->exactly($getStoreId))->method('getStoreId')->willReturn($storeId); - $observerMock->subscriberSaveBefore($eventObserverMock); } From 5943c77293c078b908f8e826af7d7fef659ebab4 Mon Sep 17 00:00:00 2001 From: Roberto Sarmiento Date: Wed, 17 Jul 2019 14:55:05 -0300 Subject: [PATCH 10/14] Commenting the three new protected methods: sEmailConfirmationRequired($subscriberSource) isMagentoSubscription($subscriberSource) isMailchimpSave($subscriberSource) #996 --- .../community/Ebizmarts/MailChimp/Model/Observer.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/code/community/Ebizmarts/MailChimp/Model/Observer.php b/app/code/community/Ebizmarts/MailChimp/Model/Observer.php index 9e5d83cd0..64a69ca43 100755 --- a/app/code/community/Ebizmarts/MailChimp/Model/Observer.php +++ b/app/code/community/Ebizmarts/MailChimp/Model/Observer.php @@ -1172,18 +1172,26 @@ protected function getStoreViewIdBySubscriber($subscriber) return $storeViewId; } + /** + * @param string $subscriberSource + * @return bool + */ protected function isEmailConfirmationRequired($subscriberSource) { return $subscriberSource === Ebizmarts_MailChimp_Model_Subscriber::SUBSCRIBE_CONFIRMATION; } + /** + * @param string $subscriberSource + * @return bool + */ protected function isMagentoSubscription($subscriberSource) { return empty($subscriberSource); } /** - * @param $subscriberSource + * @param string $subscriberSource * @return bool */ protected function isMailchimpSave($subscriberSource) From 38460dd6093846b81dd458a29a83c2a4e66b0d09 Mon Sep 17 00:00:00 2001 From: Roberto Sarmiento Date: Fri, 19 Jul 2019 14:59:10 -0300 Subject: [PATCH 11/14] 1) Renaming option name "Webhooks Delete action" to: "Webhook Delete Subscriber Action". 2) Renaming selectable options for "Webhook Delete Subscriber Action": from: "Unsubscribe customers" to: "Unsubscribe" and from: "Delete customer account" to: "Delete subscriber" 3) Changing of just renamed "Webhook Delete Subscriber Action" option in order to show it after "Create Webhook" button #992 --- .../System/Config/Source/WebhookDelete.php | 4 ++-- .../Ebizmarts/MailChimp/etc/system.xml | 20 ++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/app/code/community/Ebizmarts/MailChimp/Model/System/Config/Source/WebhookDelete.php b/app/code/community/Ebizmarts/MailChimp/Model/System/Config/Source/WebhookDelete.php index a678b20e5..80a232b67 100755 --- a/app/code/community/Ebizmarts/MailChimp/Model/System/Config/Source/WebhookDelete.php +++ b/app/code/community/Ebizmarts/MailChimp/Model/System/Config/Source/WebhookDelete.php @@ -19,8 +19,8 @@ class Ebizmarts_MailChimp_Model_System_Config_Source_WebhookDelete public function toOptionArray() { return array( - array('value' => 0, 'label' => Mage::helper('mailchimp')->__('Unsubscribe customers')), - array('value' => 1, 'label' => Mage::helper('mailchimp')->__('Delete customer account')) + array('value' => 0, 'label' => Mage::helper('mailchimp')->__('Unsubscribe')), + array('value' => 1, 'label' => Mage::helper('mailchimp')->__('Delete subscriber')) ); } } diff --git a/app/code/community/Ebizmarts/MailChimp/etc/system.xml b/app/code/community/Ebizmarts/MailChimp/etc/system.xml index 6b149af29..23b2677e7 100644 --- a/app/code/community/Ebizmarts/MailChimp/etc/system.xml +++ b/app/code/community/Ebizmarts/MailChimp/etc/system.xml @@ -219,6 +219,17 @@ 1 + + + + select + mailchimp/system_config_source_webhookDelete + 59 + 1 + 1 + 1 + + select @@ -242,15 +253,6 @@ 1 - - - select - mailchimp/system_config_source_webhookDelete - 70 - 1 - 1 - 1 - select From c480aaa9da2a0e5377d8e98b998ea6a4bb34071b Mon Sep 17 00:00:00 2001 From: Roberto Sarmiento Date: Fri, 19 Jul 2019 15:02:46 -0300 Subject: [PATCH 12/14] Trimming spaces before and after node #992 --- app/code/community/Ebizmarts/MailChimp/etc/system.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/code/community/Ebizmarts/MailChimp/etc/system.xml b/app/code/community/Ebizmarts/MailChimp/etc/system.xml index 23b2677e7..4d437ed34 100644 --- a/app/code/community/Ebizmarts/MailChimp/etc/system.xml +++ b/app/code/community/Ebizmarts/MailChimp/etc/system.xml @@ -219,7 +219,6 @@ 1 - select @@ -229,7 +228,6 @@ 1 1 - select From 5891492bf9da1cd1306fa280ac38fa826ba551e8 Mon Sep 17 00:00:00 2001 From: Roberto Sarmiento Date: Fri, 19 Jul 2019 17:03:35 -0300 Subject: [PATCH 13/14] Reusing variable $mageCoreHelper in order to get Helper just once #992 --- .../MailChimp/Model/System/Config/Source/WebhookDelete.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/code/community/Ebizmarts/MailChimp/Model/System/Config/Source/WebhookDelete.php b/app/code/community/Ebizmarts/MailChimp/Model/System/Config/Source/WebhookDelete.php index 80a232b67..77013b3a7 100755 --- a/app/code/community/Ebizmarts/MailChimp/Model/System/Config/Source/WebhookDelete.php +++ b/app/code/community/Ebizmarts/MailChimp/Model/System/Config/Source/WebhookDelete.php @@ -18,9 +18,11 @@ class Ebizmarts_MailChimp_Model_System_Config_Source_WebhookDelete */ public function toOptionArray() { + $mageCoreHelper = Mage::helper('mailchimp'); + return array( - array('value' => 0, 'label' => Mage::helper('mailchimp')->__('Unsubscribe')), - array('value' => 1, 'label' => Mage::helper('mailchimp')->__('Delete subscriber')) + array('value' => 0, 'label' => $mageCoreHelper->__('Unsubscribe')), + array('value' => 1, 'label' => $mageCoreHelper->__('Delete subscriber')) ); } } From 76240c619c2f5772b485197ac50478983bb0fddb Mon Sep 17 00:00:00 2001 From: Roberto Sarmiento Date: Mon, 22 Jul 2019 12:04:48 -0300 Subject: [PATCH 14/14] Reusing variable $mailchimpHelper in order to get Helper just once #992 --- .../MailChimp/Model/System/Config/Source/WebhookDelete.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/community/Ebizmarts/MailChimp/Model/System/Config/Source/WebhookDelete.php b/app/code/community/Ebizmarts/MailChimp/Model/System/Config/Source/WebhookDelete.php index 77013b3a7..ac9c20e4c 100755 --- a/app/code/community/Ebizmarts/MailChimp/Model/System/Config/Source/WebhookDelete.php +++ b/app/code/community/Ebizmarts/MailChimp/Model/System/Config/Source/WebhookDelete.php @@ -18,11 +18,11 @@ class Ebizmarts_MailChimp_Model_System_Config_Source_WebhookDelete */ public function toOptionArray() { - $mageCoreHelper = Mage::helper('mailchimp'); + $mailchimpHelper = Mage::helper('mailchimp'); return array( - array('value' => 0, 'label' => $mageCoreHelper->__('Unsubscribe')), - array('value' => 1, 'label' => $mageCoreHelper->__('Delete subscriber')) + array('value' => 0, 'label' => $mailchimpHelper->__('Unsubscribe')), + array('value' => 1, 'label' => $mailchimpHelper->__('Delete subscriber')) ); } }