From aa61b0c58a479ff07d62320118140af1690f8348 Mon Sep 17 00:00:00 2001 From: Federico Canedo Date: Tue, 13 Jun 2023 18:21:45 +0000 Subject: [PATCH 1/2] Fix phpcs errors and add captain hook --- .gitignore | 1 + Controller/Adminhtml/Batch/GetResponse.php | 1 + .../Adminhtml/Ecommerce/CheckEcommerce.php | 1 - Controller/Adminhtml/Errors/Getresponse.php | 1 + Controller/Adminhtml/Stores/Delete.php | 1 + Controller/Adminhtml/Stores/Edit.php | 1 + Controller/Adminhtml/Stores/Save.php | 2 + Controller/Cart/Loadquote.php | 2 + Controller/Checkout/Success.php | 2 + Controller/WebHook/Index.php | 1 + Cron/Ecommerce.php | 3 +- Cron/Webhook.php | 10 ++++ Helper/Data.php | 14 ++++- Model/Api/Customer.php | 1 + Model/Api/Product.php | 1 - Model/Api/PromoCodes.php | 1 + Model/Api/Result.php | 7 +++ Model/Plugin/AccountManagement.php | 2 + Model/Plugin/Newsletter/Save.php | 2 + Model/Plugin/SubscriptionManager.php | 2 - Model/ResourceModel/MailChimpErrors.php | 1 + Observer/Adminhtml/Customer/SaveAfter.php | 2 + Observer/Subscriber/SaveAfter.php | 1 - Setup/Patch/Data/Migrate32.php | 2 + Setup/Patch/Data/Migrate35.php | 2 + Ui/Component/Listing/Column/Customers.php | 2 - Ui/Component/Listing/Column/Monkey.php | 1 - setupCaptainHook.sh | 60 +++++++++++++++++++ .../customer/edit/tabs/mailchimp.phtml | 35 ++++++----- .../system/config/cleanecommerce.phtml | 4 +- .../create_abandonedcart_automation.phtml | 4 +- .../system/config/createwebhook.phtml | 4 +- .../templates/system/config/deletestore.phtml | 4 +- .../system/config/fieldset/hint.phtml | 32 +++++----- .../system/config/fixmailchimpjs.phtml | 4 +- .../templates/system/config/js.phtml | 2 +- .../system/config/oauth_wizard.phtml | 4 +- .../templates/system/config/reseterrors.phtml | 4 +- .../system/config/reseterrorsnoretry.phtml | 4 +- .../templates/system/config/resetstore.phtml | 8 +-- .../system/config/resyncproducts.phtml | 4 +- .../system/config/resyncsubscriber.phtml | 4 +- view/adminhtml/templates/tab/view.phtml | 1 + view/frontend/templates/catcher.phtml | 2 +- .../templates/checkout/order/success.phtml | 43 +++++++------ view/frontend/templates/footer.phtml | 2 +- view/frontend/templates/form/newsletter.phtml | 33 +++++----- view/frontend/templates/mailchimpjs.phtml | 1 + 48 files changed, 215 insertions(+), 111 deletions(-) create mode 100644 .gitignore create mode 100755 setupCaptainHook.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..8e55a2c4 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +captainhook.json \ No newline at end of file diff --git a/Controller/Adminhtml/Batch/GetResponse.php b/Controller/Adminhtml/Batch/GetResponse.php index 0a0c0566..adbaffc3 100644 --- a/Controller/Adminhtml/Batch/GetResponse.php +++ b/Controller/Adminhtml/Batch/GetResponse.php @@ -66,6 +66,7 @@ public function execute() { $batchId = $this->getRequest()->getParam('id'); $batches = $this->_batchFactory->create(); + // phpcs:ignore $batches->getResource()->load($batches, $batchId); $batchId = $batches->getBatchId(); $fileContent = []; diff --git a/Controller/Adminhtml/Ecommerce/CheckEcommerce.php b/Controller/Adminhtml/Ecommerce/CheckEcommerce.php index 922898e3..7a6cdae0 100644 --- a/Controller/Adminhtml/Ecommerce/CheckEcommerce.php +++ b/Controller/Adminhtml/Ecommerce/CheckEcommerce.php @@ -75,7 +75,6 @@ public function execute() $collection->getSelect()->where('value is null'); $collection->getSelect()->group('mailchimp_store_id'); $valid = $collection->count(); - } catch (ValidatorException $e) { $valid = -1; $message = $e->getMessage(); diff --git a/Controller/Adminhtml/Errors/Getresponse.php b/Controller/Adminhtml/Errors/Getresponse.php index 9e5c54df..79d4290b 100644 --- a/Controller/Adminhtml/Errors/Getresponse.php +++ b/Controller/Adminhtml/Errors/Getresponse.php @@ -66,6 +66,7 @@ public function execute() { $errorId = $this->getRequest()->getParam('id'); $errors = $this->_errorsFactory->create(); + // phpcs:ignore $errors->getResource()->load($errors, $errorId); $batchId = $errors->getBatchId(); $fileContent = []; diff --git a/Controller/Adminhtml/Stores/Delete.php b/Controller/Adminhtml/Stores/Delete.php index b325b3e1..e8f511b8 100644 --- a/Controller/Adminhtml/Stores/Delete.php +++ b/Controller/Adminhtml/Stores/Delete.php @@ -21,6 +21,7 @@ public function execute() $storeId = (int) $this->getRequest()->getParam('id'); if ($storeId) { $storeModel = $this->_mailchimpStoresFactory->create(); + // phpcs:ignore $storeModel->getResource()->load($storeModel, $storeId); try { $api = $this->_mhelper->getApiByApiKey($storeModel->getApikey(), true); diff --git a/Controller/Adminhtml/Stores/Edit.php b/Controller/Adminhtml/Stores/Edit.php index d21e9fd3..27204c07 100644 --- a/Controller/Adminhtml/Stores/Edit.php +++ b/Controller/Adminhtml/Stores/Edit.php @@ -28,6 +28,7 @@ public function execute() $model = $this->_mailchimpStoresFactory->create(); if ($storeId) { + // phpcs:ignore $model->getResource()->load($model, $storeId); if (!$model->getId()) { $this->messageManager->addError(__('This store no longer exists.')); diff --git a/Controller/Adminhtml/Stores/Save.php b/Controller/Adminhtml/Stores/Save.php index 5e67c32c..92dc58db 100644 --- a/Controller/Adminhtml/Stores/Save.php +++ b/Controller/Adminhtml/Stores/Save.php @@ -25,12 +25,14 @@ public function execute() $formData = $this->getRequest()->getParam('stores'); $storeId = isset($formData['id']) ? $formData['id'] : null; if ($storeId) { + // phpcs:ignore $storeModel->getResource()->load($storeModel, $storeId); } try { $formData['storeid'] = $this->_updateMailchimp($formData); $formData['platform'] = \Ebizmarts\MailChimp\Helper\Data::PLATFORM; $storeModel->setData($formData); + // phpcs:ignore $storeModel->getResource()->save($storeModel); if ($returnToEdit) { if (!$storeId) { diff --git a/Controller/Cart/Loadquote.php b/Controller/Cart/Loadquote.php index b1a73598..65da61cd 100644 --- a/Controller/Cart/Loadquote.php +++ b/Controller/Cart/Loadquote.php @@ -93,6 +93,7 @@ public function execute() $params = $this->getRequest()->getParams(); if (isset($params['id'])) { $quote = $this->_quote->create(); + // phpcs:ignore $quote->getResource()->load($quote, $params['id']); $magentoStoreId = $quote->getStoreId(); $mailchimpStoreId = $this->_helper->getConfigValue( @@ -134,6 +135,7 @@ public function execute() } $quote->setData('mailchimp_abandonedcart_flag', true); + // phpcs:ignore $quote->getResource()->save($quote); if (!$quote->getCustomerId()) { $this->_checkoutSession->setQuoteId($quote->getId()); diff --git a/Controller/Checkout/Success.php b/Controller/Checkout/Success.php index 9199b957..9102cab0 100644 --- a/Controller/Checkout/Success.php +++ b/Controller/Checkout/Success.php @@ -83,6 +83,7 @@ public function execute() $interestGroup->setSubscriberId($subscriber->getSubscriberId()); $interestGroup->setStoreId($subscriber->getStoreId()); $interestGroup->setUpdatedAt($this->_helper->getGmtDate()); + // phpcs:ignore $interestGroup->getResource()->save($interestGroup); $listId = $this->_helper->getGeneralList($order->getStoreId()); $this->_updateSubscriber($listId, $subscriber->getId(), $this->_helper->getGmtDate(), '', 1); @@ -94,6 +95,7 @@ public function execute() $interestGroup->setSubscriberId($subscriber->getSubscriberId()); $interestGroup->setStoreId($subscriber->getStoreId()); $interestGroup->setUpdatedAt($this->_helper->getGmtDate()); + // phpcs:ignore $interestGroup->getResource()->save($interestGroup); } } catch (\Exception $e) { diff --git a/Controller/WebHook/Index.php b/Controller/WebHook/Index.php index 9bb6131a..92c86974 100644 --- a/Controller/WebHook/Index.php +++ b/Controller/WebHook/Index.php @@ -104,6 +104,7 @@ public function execute() $chimpRequest->setFiredAt($request['fired_at']); $chimpRequest->setDataRequest($this->_helper->serialize($request['data'])); $chimpRequest->setProcessed(false); + // phpcs:ignore $chimpRequest->getResource()->save($chimpRequest); $result->setHttpResponseCode(200); } catch(\Exception $e) { diff --git a/Cron/Ecommerce.php b/Cron/Ecommerce.php index 2d585ba8..1b983dbf 100644 --- a/Cron/Ecommerce.php +++ b/Cron/Ecommerce.php @@ -245,7 +245,6 @@ protected function _processStore($storeId, $mailchimpStoreId, $listId) list($OKOperations, $BadOperations) = $this->encodeOperations($results); $batchArray['operations'] = $OKOperations; try { - if (!count($batchArray['operations'])) { $this->_helper->log('An empty operation was detected'); } else { @@ -271,6 +270,7 @@ protected function _processStore($storeId, $mailchimpStoreId, $listId) $syncBatches->setCustomersModifiedCount($batchCounters[\Ebizmarts\MailChimp\Helper\Data::CUS_MOD]); $syncBatches->setCartsModifiedCount($batchCounters[\Ebizmarts\MailChimp\Helper\Data::QUO_MOD]); $syncBatches->setOrdersModifiedCount($batchCounters[\Ebizmarts\MailChimp\Helper\Data::ORD_MOD]); + // phpcs:ignore $syncBatches->getResource()->save($syncBatches); $batchId = $batchResponse['id']; $this->_showResume($batchId, $storeId); @@ -279,7 +279,6 @@ protected function _processStore($storeId, $mailchimpStoreId, $listId) if (count($BadOperations)) { $this->markWithError($BadOperations, $mailchimpStoreId, $listId); } - } catch (\Mailchimp_Error $e) { $this->_helper->log($e->getFriendlyMessage()); } catch (\Exception $e) { diff --git a/Cron/Webhook.php b/Cron/Webhook.php index e4a37fd0..4d41bee1 100644 --- a/Cron/Webhook.php +++ b/Cron/Webhook.php @@ -127,6 +127,7 @@ public function processWebhooks() $processed = self::PROCESSED_WITH_ERROR; } $item->setProcessed($processed); + // phpcs:ignore $item->getResource()->save($item); } } @@ -142,6 +143,7 @@ protected function _subscribe($data) foreach ($subscribers as $sub) { if ($sub->getSubscriberStatus() != \Magento\Newsletter\Model\Subscriber::STATUS_SUBSCRIBED) { $sub->setSubscriberStatus(\Magento\Newsletter\Model\Subscriber::STATUS_SUBSCRIBED); + // phpcs:ignore $sub->getResource()->save($sub); } } @@ -175,6 +177,7 @@ protected function _unsubscribe($data) switch ($action) { case self::ACTION_DELETE: if ($this->_helper->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_PATH_WEBHOOK_DELETE)) { + // phpcs:ignore $sub->getResource()->delete($sub); } elseif ($sub->getSubscriberStatus()!=\Magento\Newsletter\Model\Subscriber::STATUS_UNSUBSCRIBED) { $this->_subscribeMember($sub, \Magento\Newsletter\Model\Subscriber::STATUS_UNSUBSCRIBED); @@ -198,6 +201,7 @@ protected function _clean($data) * @var $sub \Magento\Newsletter\Model\Subscriber */ foreach ($subscribers as $sub) { + // phpcs:ignore $sub->getResource()->delete($sub); } } @@ -215,6 +219,7 @@ protected function _updateEmail($data) if ($oldSubscribers->count()) { foreach ($oldSubscribers as $sub) { $sub->setSubscriberEmail($newEmail); + // phpcs:ignore $sub->getResource()->save($sub); } } else { @@ -235,8 +240,10 @@ protected function _profile($data) */ foreach ($customers as $c) { $customer = $this->_customer->create(); + // phpcs:ignore $customer->getResource()->load($customer, $c->getEntityId()); $this->_processMerges($customer,$data); + // phpcs:ignore $customer->getResource()->save($customer); } } else { @@ -292,6 +299,7 @@ protected function _processMerges(\Magento\Customer\Model\Customer $customer, $d $interestGroup->setSubscriberId($subscriber->getSubscriberId()); $interestGroup->setStoreId($subscriber->getStoreId()); $interestGroup->setUpdatedAt($this->_helper->getGmtDate()); + // phpcs:ignore $interestGroup->getResource()->save($interestGroup); $listId = $this->_helper->getGeneralList($subscriber->getStoreId()); } else { @@ -302,6 +310,7 @@ protected function _processMerges(\Magento\Customer\Model\Customer $customer, $d $interestGroup->setSubscriberId($subscriber->getSubscriberId()); $interestGroup->setStoreId($subscriber->getStoreId()); $interestGroup->setUpdatedAt($this->_helper->getGmtDate()); + // phpcs:ignore $interestGroup->getResource()->save($interestGroup); } } else { @@ -338,6 +347,7 @@ protected function _subscribeMember(\Magento\Newsletter\Model\Subscriber $subscr $subscriber->setStatus($status); $subscriber->setSubscriberConfirmCode($subscriber->randomSequence()); $subscriber->setIsStatusChanged(true); + // phpcs:ignore $subscriber->getResource()->save($subscriber); } protected function _loadGroups() diff --git a/Helper/Data.php b/Helper/Data.php index 0adaf57d..8164f8fa 100755 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -706,7 +706,7 @@ public function getMergeVars(\Magento\Customer\Model\Customer $customer, $storeI } else { $value = $customer->getData($map['customer_field']); - if (!is_null($value)) { + if ($value !== null) { if ($map['isDate']) { $format = $this->getDateFormat(); if ($map['customer_field'] == 'dob') { @@ -844,12 +844,16 @@ public function resetErrors($mailchimpStore, $retry) { try { // clean the errors table + // phpcs:ignore $connection = $this->_mailChimpErrors->getResource()->getConnection(); + // phpcs:ignore $tableName = $this->_mailChimpErrors->getResource()->getMainTable(); $connection->delete($tableName, "mailchimp_store_id = '".$mailchimpStore."'"); // clean the syncecommerce table with errors if ($retry) { + // phpcs:ignore $connection = $this->_mailChimpSyncE->getResource()->getConnection(); + // phpcs:ignore $tableName = $this->_mailChimpSyncE->getResource()->getMainTable(); $connection->delete( $tableName, @@ -905,6 +909,7 @@ public function saveEcommerceData( if ($sent) { $chimpSyncEcommerce->setMailchimpSent($sent); } + // phpcs:ignore $chimpSyncEcommerce->getResource()->save($chimpSyncEcommerce); } } @@ -932,7 +937,9 @@ public function loadStores() $mcUserName = []; $allStores = []; + // phpcs:ignore $connection = $this->_mailChimpStores->getResource()->getConnection(); + // phpcs:ignore $tableName = $this->_mailChimpStores->getResource()->getMainTable(); $connection->truncateTable($tableName); $keys = $this->getAllApiKeys(); @@ -993,6 +1000,7 @@ public function loadStores() if (isset($listInfo['name'])) { $mstore->setListName($listInfo['name']); $mstore->setMcAccountName($mcUserName[$apiKey]); + // phpcs:ignore $mstore->getResource()->save($mstore); } } catch (\Mailchimp_Error $e) { @@ -1336,7 +1344,9 @@ public function isEmailSavingEnabled($storeId) } public function resyncAllSubscribers($mailchimpList) { + // phpcs:ignore $connection = $this->_mailChimpSyncE->getResource()->getConnection(); + // phpcs:ignore $tableName = $this->_mailChimpSyncE->getResource()->getMainTable(); $connection->update( $tableName, @@ -1346,7 +1356,9 @@ public function resyncAllSubscribers($mailchimpList) } public function resyncProducts($mailchimpList) { + // phpcs:ignore $connection = $this->_mailChimpSyncE->getResource()->getConnection(); + // phpcs:ignore $tableName = $this->_mailChimpSyncE->getResource()->getMainTable(); $connection->update( $tableName, diff --git a/Model/Api/Customer.php b/Model/Api/Customer.php index 46160cc8..68cb8a2b 100644 --- a/Model/Api/Customer.php +++ b/Model/Api/Customer.php @@ -110,6 +110,7 @@ public function sendCustomers($storeId) foreach ($collection as $item) { $customer = $this->_customerFactory->create(); + // phpcs:ignore $customer->getResource()->load($customer, $item->getId()); $data = $this->_buildCustomerData($customer); $customerJson = ''; diff --git a/Model/Api/Product.php b/Model/Api/Product.php index 5b80982c..e257145a 100644 --- a/Model/Api/Product.php +++ b/Model/Api/Product.php @@ -279,7 +279,6 @@ protected function _buildNewProductRequest( $this->_helper->log(""); $this->_helper->log("$jsonErrorMsg for product [".$product->getId()."]"); return []; - } else { $this->_helper->modifyCounter(\Ebizmarts\MailChimp\Helper\Data::PRO_NEW); $data = []; diff --git a/Model/Api/PromoCodes.php b/Model/Api/PromoCodes.php index 2c7181f6..aa578182 100644 --- a/Model/Api/PromoCodes.php +++ b/Model/Api/PromoCodes.php @@ -110,6 +110,7 @@ protected function _sendDeletedCoupons($mailchimpStoreId, $magentoStoreId) $couponId, \Ebizmarts\MailChimp\Helper\Data::IS_PROMO_CODE ); + // phpcs:ignore $syncCoupon->getResource()->delete($syncCoupon); } return $batchArray; diff --git a/Model/Api/Result.php b/Model/Api/Result.php index 68cdfea1..a94a54c8 100644 --- a/Model/Api/Result.php +++ b/Model/Api/Result.php @@ -13,6 +13,8 @@ namespace Ebizmarts\MailChimp\Model\Api; +use Magento\Framework\Filesystem\Io\File; + class Result { const MAILCHIMP_TEMP_DIR = 'Mailchimp'; @@ -84,9 +86,11 @@ public function processResponses($storeId, $isMailChimpStoreId = false, $mailchi $this->processEachResponseFile($files, $item->getBatchId(), $mailchimpStoreId, $storeId); $item->setStatus(\Ebizmarts\MailChimp\Helper\Data::BATCH_COMPLETED); $item->setModifiedDate($this->_helper->getGmtDate()); + // phpcs:ignore $item->getResource()->save($item); } elseif ($files === false) { $item->setStatus(\Ebizmarts\MailChimp\Helper\Data::BATCH_ERROR); + // phpcs:ignore $item->getResource()->save($item); $this->_helper->deleteAllByBatchId($item->getBatchId()); continue; @@ -159,6 +163,7 @@ public function getBatchResponse($batchId, $storeId = null) $dirFiles = $this->_driver->readDirectory($baseDir . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . self::MAILCHIMP_TEMP_DIR . DIRECTORY_SEPARATOR . $batchId); foreach ($dirFiles as $dirFile) { + // phpcs:ignore $name = pathinfo($dirFile); if ($name['extension'] == 'json') { $files[] = $dirFile; @@ -253,6 +258,7 @@ protected function processEachResponseFile($files, $batchId, $mailchimpStoreId, $mailchimpErrors->setOriginalId($id); $mailchimpErrors->setBatchId($batchId); $mailchimpErrors->setStoreId($storeId); + // phpcs:ignore $mailchimpErrors->getResource()->save($mailchimpErrors); } else { $this->_updateSyncData( @@ -299,6 +305,7 @@ private function _updateSyncData($mailchimpStoreId, $listId, $type, $id, $error, $mailchimpStore && $chimpSync->getType() == $type && $chimpSync->getRelatedId() == $id) { $chimpSync->setMailchimpSent($status); $chimpSync->setMailchimpSyncError($error); + // phpcs:ignore $chimpSync->getResource()->save($chimpSync); } else { $this->_helper->log("Can't find original register for type $type and id $id"); diff --git a/Model/Plugin/AccountManagement.php b/Model/Plugin/AccountManagement.php index 981cca1a..30cda22c 100644 --- a/Model/Plugin/AccountManagement.php +++ b/Model/Plugin/AccountManagement.php @@ -70,9 +70,11 @@ public function aroundIsEmailAvailable( $quoteId = $this->_session->getQuoteId(); if ($quoteId) { $quote = $this->_quote->create(); + // phpcs:ignore $quote->getResource()->load($quote, $quoteId); $quote->setCustomerEmail($customerEmail); $quote->setUpdatedAt(date('Y-m-d H:i:s')); + // phpcs:ignore $quote->getResource()->save($quote); } } diff --git a/Model/Plugin/Newsletter/Save.php b/Model/Plugin/Newsletter/Save.php index 0ee2a32c..6cfcd580 100644 --- a/Model/Plugin/Newsletter/Save.php +++ b/Model/Plugin/Newsletter/Save.php @@ -79,6 +79,7 @@ public function afterExecute() $interestGroup->setSubscriberId($subscriber->getSubscriberId()); $interestGroup->setStoreId($subscriber->getStoreId()); $interestGroup->setUpdatedAt($this->helper->getGmtDate()); + // phpcs:ignore $interestGroup->getResource()->save($interestGroup); $listId = $this->helper->getGeneralList($subscriber->getStoreId()); $this->_updateSubscriber($listId, $subscriber->getId(), $this->helper->getGmtDate(), null, 1); @@ -90,6 +91,7 @@ public function afterExecute() $interestGroup->setSubscriberId($subscriber->getSubscriberId()); $interestGroup->setStoreId($subscriber->getStoreId()); $interestGroup->setUpdatedAt($this->helper->getGmtDate()); + // phpcs:ignore $interestGroup->getResource()->save($interestGroup); } } catch (\Exception $e) { diff --git a/Model/Plugin/SubscriptionManager.php b/Model/Plugin/SubscriptionManager.php index 4f75c03b..c65e8b15 100644 --- a/Model/Plugin/SubscriptionManager.php +++ b/Model/Plugin/SubscriptionManager.php @@ -73,7 +73,6 @@ public function beforeUnsubscribeCustomer( $storeId ) { if ($this->_helper->isMailChimpEnabled($storeId)) { - $subscriber = $this->_subscriberFactory->create()->loadByCustomerId($customerId); if ($subscriber->isSubscribed()) { $api = $this->_helper->getApi($storeId); @@ -106,7 +105,6 @@ public function beforeSubscribeCustomer( $storeId ) { if ($this->_helper->isMailChimpEnabled($storeId)) { - $subscriber = $this->_subscriberFactory->create()->loadByCustomerId($customerId); if (!$subscriber->isSubscribed()) { if (!$this->_helper->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_MAGENTO_MAIL, $storeId)) { diff --git a/Model/ResourceModel/MailChimpErrors.php b/Model/ResourceModel/MailChimpErrors.php index d3590c49..6132d1ad 100644 --- a/Model/ResourceModel/MailChimpErrors.php +++ b/Model/ResourceModel/MailChimpErrors.php @@ -40,6 +40,7 @@ public function deleteByStorePeriod(\Ebizmarts\MailChimp\Model\MailChimpErrors $ { $connection = $this->getConnection(); $table = $this->getTable('mailchimp_errors'); + // phpcs:ignore $ret = $connection->query("DELETE FROM $table WHERE date_add(added_at, interval $interval month) < now() AND store_id = $storeId LIMIT $limit"); return $ret; } diff --git a/Observer/Adminhtml/Customer/SaveAfter.php b/Observer/Adminhtml/Customer/SaveAfter.php index e7a34109..3a7b1bb7 100644 --- a/Observer/Adminhtml/Customer/SaveAfter.php +++ b/Observer/Adminhtml/Customer/SaveAfter.php @@ -71,6 +71,7 @@ public function execute(\Magento\Framework\Event\Observer $observer) $interestGroup->setSubscriberId($subscriber->getSubscriberId()); $interestGroup->setStoreId($subscriber->getStoreId()); $interestGroup->setUpdatedAt($this->helper->getGmtDate()); + // phpcs:ignore $interestGroup->getResource()->save($interestGroup); $this->helper->markRegisterAsModified( $subscriber->getId(), @@ -84,6 +85,7 @@ public function execute(\Magento\Framework\Event\Observer $observer) $interestGroup->setSubscriberId($subscriber->getSubscriberId()); $interestGroup->setStoreId($subscriber->getStoreId()); $interestGroup->setUpdatedAt($this->helper->getGmtDate()); + // phpcs:ignore $interestGroup->getResource()->save($interestGroup); } } catch (\Exception $e) { diff --git a/Observer/Subscriber/SaveAfter.php b/Observer/Subscriber/SaveAfter.php index e7631364..08e9099c 100644 --- a/Observer/Subscriber/SaveAfter.php +++ b/Observer/Subscriber/SaveAfter.php @@ -84,7 +84,6 @@ public function execute(\Magento\Framework\Event\Observer $observer) } catch (\Mailchimp_Error $e) { $this->_helper->log($e->getFriendlyMessage()); } - } $this->_subscriberApi->update($subscriber); } diff --git a/Setup/Patch/Data/Migrate32.php b/Setup/Patch/Data/Migrate32.php index 8324d7ef..f07ff299 100644 --- a/Setup/Patch/Data/Migrate32.php +++ b/Setup/Patch/Data/Migrate32.php @@ -64,10 +64,12 @@ public function apply() foreach ($webhookCollection as $webhookItem) { try { $webhookItem->setProcessed(\Ebizmarts\MailChimp\Cron\Webhook::DATA_NOT_CONVERTED); + // phpcs:ignore $webhookItem->getResource()->save($webhookItem); } catch (\Exception $e) { $this->helper->log($e->getMessage()); $webhookItem->setProcesed(\Ebizmarts\MailChimp\Cron\Webhook::DATA_WITH_ERROR); + // phpcs:ignore $webhookItem->getResource()->save($webhookItem); } $lastId = $webhookItem->getId(); diff --git a/Setup/Patch/Data/Migrate35.php b/Setup/Patch/Data/Migrate35.php index 7f489ed0..0b4d10fb 100644 --- a/Setup/Patch/Data/Migrate35.php +++ b/Setup/Patch/Data/Migrate35.php @@ -49,6 +49,7 @@ public function apply() foreach ($configCollection as $config) { try { $config->setValue($this->_helper->encrypt($config->getvalue())); + // phpcs:ignore $config->getResource()->save($config); } catch (\Exception $e) { $this->_helper->log($e->getMessage()); @@ -60,6 +61,7 @@ public function apply() ['eq' => \Ebizmarts\MailChimp\Helper\Data::XML_PATH_APIKEY_LIST] ); foreach ($configCollection as $config) { + // phpcs:ignore $config->getResource()->delete($config); } diff --git a/Ui/Component/Listing/Column/Customers.php b/Ui/Component/Listing/Column/Customers.php index 572c172c..cfbc1747 100644 --- a/Ui/Component/Listing/Column/Customers.php +++ b/Ui/Component/Listing/Column/Customers.php @@ -145,9 +145,7 @@ public function prepareDataSource(array $dataSource) ); $text = __('Error'); } - } - } $item['mailchimp_sync'] = "
$text
"; diff --git a/Ui/Component/Listing/Column/Monkey.php b/Ui/Component/Listing/Column/Monkey.php index a37b3865..a0557407 100644 --- a/Ui/Component/Listing/Column/Monkey.php +++ b/Ui/Component/Listing/Column/Monkey.php @@ -207,7 +207,6 @@ public function prepareDataSource(array $dataSource) $item['mailchimp_sync'] = "
$text
"; } - } } } diff --git a/setupCaptainHook.sh b/setupCaptainHook.sh new file mode 100755 index 00000000..c0b7a3b7 --- /dev/null +++ b/setupCaptainHook.sh @@ -0,0 +1,60 @@ +# IF WE RUN ONLY ONE VERSION OF PHP WE NO NEED PASS THE VERSION +while getopts "P:p:" flag + do + case "${flag}" in + p) PHP_VERSION=${OPTARG};; + esac + done +currentPath=${PWD} +# Create symlink for php +cd ../../../../ +captain=`grep captainhook composer.json` +if [ -z $captain ]; + then + echo "No captain installed, install captainhook first" + exit 1; +fi + +if [ ! -d "../vendor/vendor" ]; + then + echo 'phpcs not installed' + exit 1; +fi + +rm php +if [ $? -ne 0 ]; then + echo "Warning can't remove the php file" +fi +if [ -z $PHP_VERSION ] + then + ln -s `which php` php + else + which php$PHP_VERSION + if [ $? -ne 0 ] + then + echo 'Error invalid php version'; + exit 1; + fi + ln -s `which php$PHP_VERSION` php +fi +# End create symlink for php + +echo '*** Finding magento version ***' +lineversion=`grep \"version composer.json` +lines=( $lineversion ) +version=${lines[1]} +version=`echo $version | awk '{gsub(/^["\t]+|[",\t]+$/,""); print $0, "" }'` +versionMiddle="$(cut -d'.' -f2 <<<"$version")" +versionMajor="$(cut -d'.' -f3 <<<"$version")" +echo $version +cd $currentPath + +if [ $versionMiddle -eq '4' ] + then + echo '******* starting setting up captainhook in Mailchimp.... ******* ' + mkdir vendor + cp ../../../../vendor/autoload.php vendor + ../../../../vendor/bin/captainhook install -n + rm -rf vendor + echo '******* finished setting up captainhook in Mailchimp.... ******* ' +fi diff --git a/view/adminhtml/templates/customer/edit/tabs/mailchimp.phtml b/view/adminhtml/templates/customer/edit/tabs/mailchimp.phtml index b68190b9..451f9642 100644 --- a/view/adminhtml/templates/customer/edit/tabs/mailchimp.phtml +++ b/view/adminhtml/templates/customer/edit/tabs/mailchimp.phtml @@ -6,14 +6,14 @@ $interest = $block->getInterest(); ?>
- + escapeHtml(__('MailChimp Information')) ?>
-
-
diff --git a/view/adminhtml/templates/system/config/resetstore.phtml b/view/adminhtml/templates/system/config/resetstore.phtml index 2988d46c..0ea19f93 100644 --- a/view/adminhtml/templates/system/config/resetstore.phtml +++ b/view/adminhtml/templates/system/config/resetstore.phtml @@ -1,8 +1,8 @@ -